Pension Payroll
1. **Problem Statement:**
You are asked to create and manage a Pension Payroll Database in MS Access and write a QBASIC program to process given data.
2. **MS Access Pension Payroll Database:**
- Create a database named Pen-Info.
- Create a table PenPay with fields: PayNo, Names, Sex, Age, Date of Last Pay.
- Set PayNo as the primary key.
- Create another table PenAccts with fields: PayNo, Basic-pay, Allowances, Tax, Deductions, Gross pay, Net-pay.
- Populate both tables with 5 records each.
- Steps to make PayNo primary key:
1. Open PenPay table in Design View.
2. Select the PayNo field.
3. Click the Primary Key button on the toolbar.
4. Save the table.
- To print and screenshot, use MS Access print and screenshot tools.
- To create a report showing PayNo, Names, GrossPay, NetPay:
1. Create a query joining PenPay and PenAccts on PayNo.
2. Select fields PayNo, Names, Gross pay, Net-pay.
3. Use the Report Wizard to generate the report.
3. **QBASIC Program:**
- Data: 30, 20, 40, 20, 30, 60, 80, 20, 40, 20
- Use READ and DATA statements to input numbers.
- Calculate sum: $$\text{sum} = \sum_{i=1}^{10} x_i$$
- Calculate average: $$\text{average} = \frac{\text{sum}}{10}$$
- Print sum and average.
4. **Sample QBASIC code snippet:**
```basic
DIM numbers(10) AS INTEGER
FOR i = 1 TO 10
READ numbers(i)
NEXT i
sum = 0
FOR i = 1 TO 10
sum = sum + numbers(i)
NEXT i
average = sum / 10
PRINT "Sum: "; sum
PRINT "Average: "; average
DATA 30, 20, 40, 20, 30, 60, 80, 20, 40, 20
```
5. **Explanation:**
- The READ statement reads data values into an array.
- The sum is calculated by adding all elements.
- The average is the sum divided by the number of elements.
- Printing outputs the results.
**Final answers:**
- Sum = 360
- Average = 36