MCS1514 – Lab 1 – Spring 2016 This program is an exercise in

advertisement
MCS1514 – Lab 1 – Spring 2016
This program is an exercise in using loops and functions that pass values in both directions (to and from a
function). You will calculate the payroll of several employees at a company. After processing the
employees’ information, you will provide a payroll summary. This program is to use both input and output
files.
INPUT (for each employee)
Employee number
Hourly wage
Hours worked
CALCULATIONS
1) Employee gross pay is hours worked multiplied by hourly wage.
a. If hours worked for an employee are 35 or less then the employee receives a $.15 per
hour bonus. Show this in the output by displaying an asterisk * after their hours worked.
b. If hours worked for an employee are more than 40 hours then they receive 1.5 times their
wages for hours worked over 40 hours. Show this in the output by displaying a $ after
their hours worked.
2) State tax is 5.42 percent (.0542) of the employee gross pay.
3) Social Security tax is 7 percent (.07) of the employee gross pay.
4) Federal tax is 16 percent (.16) of the employee gross pay.
5) Net pay is the gross pay minus the taxes of state, federal, and social security.
6) Totals for gross pay, state tax, federal tax, and social security tax will need to be printed for the
company.
SAMPLE INPUT FILE
1121
9876
3333
2121
9999
15.12 40
9.50
47
22.00 35
5.45
43
10.00 25
(20%) SAMPLE OUTPUT FILE
Employee Payroll
Employee
Hours
Rate
Gross
Net
Fed
State
Soc Sec
1121
40
15.12
604.80
432.91
96.77
32.78
42.34
9876
47$
9.50
479.75
343.41
76.76
26.00
33.58
3333
35* 22.00
775.25
554.92
124.09
42.02
54.27
2121
43$
5.45
242.53
173.60
38.80
13.15
16.98
9999
25* 10.00
253.75
181.64
40.60
13.75
17.76
SUMMARY – Totals for All Employees



Gross Pay
Net Pay
Federal Tax
State Tax
Soc Security
2356.08
1686.48
376.97
127.70
164.93
(10%) Output must line up in columns as shown above. This includes numbers to be lined up
under headings (right justified)
(5%) Check if your program works correctly by running with the sample data above
(5%) I will do a final run using my data.
GENERAL REQUIREMENTS
1) You must use main() and at least three additional functions: process_payroll(),
process_employee(), and print_summary().
2) (10%) The function process_employee() performs the following tasks:
a. Reads the individual employee payroll information
b. Returns the value read using parameters
c. Function returns (one 1) if employee information is read successfully or (zero 0) if
employee information is not read successfully.
3) (10%) The function process_payroll() performs the following tasks:
a. Print “Employee Payroll” header message
b. Print the headings for the columns (Employee, Hours, Rate, etc.)
c. Call process_employee() [from inside a loop] until 0 is returned
d. For each employee calculate and record:
i. Gross pay, net pay, fed tax, state tax, soc security
ii. Update the variables required to print summary
iii. Print out one line for each employee as shown
4) (10%) The function print_summary() performs the following tasks:
a. Print out the “Summary …” message line
b. Prints out the column headings (Gross Pay, Net Pay, etc.)
c. Prints out the totals which have been accumulated (running total kept)
5) (5%) Make up variable names that are meaningful.
6) (5%) Indent consistently and use white space (blanks and blank lines) appropriately.
7) (5%) Have a block comment at the start of your program with name, etc.
8) (5%) Have a block comment before each function with the function name and a short description.
9) (5%) Use additional comments as necessary.
10) (5%) Use symbolic constant values such as federal tax (e.g. const float FEDERAL_TAX = 0.16;)
11) (5%) Prototype your functions.
12) (5%) Do NOT use global variables
Download