P04 Monthend Payroll Loop - 30 points (source code and sample outputs) |
|
This program will be used by payroll clerks to determine the total gross pay
for the month by processing the weekly hours worked of their employees. We
will not be concerned with calculating taxes and net pay.
The user will be asked to input the number of employees to process.
If a zero is entered, the loop to process the number of employees should be by passed.
Only positive integers and zero should be allowed as input, so negative numbers
should result on a error message being displayed.
For each employee entered:
Prompt for the hourly rate.
The rate must be between $5.25 and $30.00 inclusive, else display an error message.
Prompt for the number of hours worked in each of the four weeks of the month.
The input should be on the same line separated by spaces.
The hours will be entered as whole numbers (integers).
The hours worked for any week can be zero, but all four weeks cannot be zero.
The hours worked must be between 0 and 60 inclusive.
Display a specific error message for each of the three validations.
Calculate the gross pay for each week.
For the hours between 1 and 40, the employee is paid at their hourly rate.
For the hours between 41 and 50, the employee is paid 1.5 times the hourly rate.
For the hours between 51 and 60, the employee is paid double time (2.0).
The overtime rates must be stored in constant variables such as:
RATE1 = 1.0 RATE2 = 1.5 RATE3 = 2.0
If RATE1 is defined, do NOT use it in the formula because multiplying by one
gives the same value.
Display a detail line for each employee that contains the hourly rate, hours worked,
amount earned at each rate, and the gross pay for each week for a total of 4 lines.
Display a total line for each employee that contains the total hours, totals at
each rate, and total gross pay for the month. See the sample output below.
After processing all of the employees, display report totals that include the total
hours, totals at each rate, the total gross pay of all employees processed. In
addition display the number of employees processed, and the average total gross pay
of all of the employees processed. Before dividing for the average, make sure the
employee count is not equal to zero. See the sample output below.
Requirements:
Source code listing, sample output for the three cases and sample output
of at least 3 of the error messages displayed by the data validation routines.
You will copy and paste text from various screens into one output.txt file.
For the prompt "Enter the number of employees to process:", enter a value of 3,
and then use the cases listed below to generate the sample output.
Cases: Hourly Hours Hours Hours Hours
Case # Rate Week1 Week2 Week3 Week4
------ ----- ----- ----- ----- -----
1 10.25 35 45 55 30
2 12.50 45 55 40 50
3 15.00 60 39 41 51
Sample Output:
P04 - Juan Marquez TR 1:00pm
Enter the number of employees to process.
Enter 0 (zero) to exit: 3
P04 - Juan Marquez TR 1:00pm Employee: 1
Enter the pay rate ($5.25 - $30.00): 10.25
Enter four hours worked separated by a space (0 - 60): 35 45 55 30
Week Rate Hours 1.0 1.5 2.0 Total
W1 10.25 35 358.75 0.00 0.00 358.75
W2 10.25 45 410.00 76.88 0.00 486.88
W3 10.25 55 410.00 153.75 102.50 666.25
W4 10.25 30 307.50 0.00 0.00 307.50
Employee Totals 165 1486.25 230.63 102.50 1819.38
Press Enter to process the next employee or the report totals:
P04 - Juan Marquez TR 1:00pm Employee: 2
Enter the pay rate ($5.25 - $30.00): 12.50
Enter four hours worked separated by a space (0 - 60): 45 55 40 50
Week Rate Hours 1.0 1.5 2.0 Total
W1 12.50 45 500.00 93.75 0.00 593.75
W2 12.50 55 500.00 187.50 125.00 812.50
W3 12.50 40 500.00 0.00 0.00 500.00
W4 12.50 50 500.00 187.50 0.00 687.50
Employee Totals 190 2000.00 468.75 125.00 2593.75
Press Enter to process the next employee or the report totals:
P04 - Juan Marquez TR 1:00pm Employee: 3
Enter the pay rate ($5.25 - $30.00): 15
Enter four hours worked separated by a space (0 - 60): 60 39 41 51
Week Rate Hours 1.0 1.5 2.0 Total
W1 15.00 60 600.00 225.00 300.00 1125.00
W2 15.00 39 585.00 0.00 0.00 585.00
W3 15.00 41 600.00 22.50 0.00 622.50
W4 15.00 51 600.00 225.00 30.00 855.00
Employee Totals 191 2385.00 472.50 330.00 3187.50
Press Enter to process the next employee or the report totals:
Report Totals 546 5871.25 1171.88 557.50 7600.63
Number of Employees: 3 Average Gross: 2533.54
Sample Error Messages:
P04 - Juan Marquez TR 1:00pm
Enter the number of employees to process.
Enter 0 (zero) to exit: -1
Error: The number of employees to process must be 0 or greater. Try again.
Enter the number of employees to process.
Enter 0 (zero) to exit: 1
P04 - Juan Marquez TR 1:00pm Employee: 1
Enter the pay rate ($5.25 - $30.00): 45
Error: The pay rate must be between $5.25 and $30.00.
Enter the pay rate ($5.25 - $30.00): 4
Error: The pay rate must be between $5.25 and $30.00.
Enter the pay rate ($5.25 - $30.00): 10
Enter four hours worked separated by a space (0 - 60): 0 0 0 0
Error: All four hours cannot be zero.
Enter four hours worked separated by a space (0 - 60): -10 30 40 70
Error: Negative values are not valid.
Error: Values may not exceed 60.
Enter four hours worked separated by a space (0 - 60): 40 40 40 40