| P05 Employee Weekly Pay Calculator with Call-By-Value Functions - 20 points (turn in source code and sample output) |
|
Reminder: Use Ctrl-C to terminate endless loops.
This program will be used by employees to determine what their weekly net pay
would be based on their hourly rate and number of hours worked.
Use constant global variable to store the following value:
OVERTIME_RATE = 1.5
Use constant local variables to store the following values:
UNION_DUES = 10.00 FICA_RATE = 6% (0.06)
FEDERAL_RATE = 15% (0.15) STATE_RATE = 5% (0.05)
The user will be asked to input their hourly rate and number of hours worked.
The data entered will be validated.
The hourly rate must be between $10.00 - $15.00 inclusive (10-15).
The hours worked must be between 1 and 50 inclusive (1-50).
The program should then calculate gross and net pay using the user input and
constants provided.
For the hours over 40 the employee gets paid 1.5 times their rate.
In addition, the net hourly rate will also be calculated and displayed, so that
employees will know what their take-home pay per hour is.
The results should be displayed on the screen with an appropriate label
preceding the value.
The amounts should line up under each other after their labels (see sample output).
The rates used to calculate FICA, federal, and state tax should be displayed
after each of the corresponding amounts.
The output should be formatted to two decimal points.
Requirements:
Source code listing and sample output for each case.
You can choose your own variable names, but the function prototypes to use are:
double inputRate();
int inputHours();
double calcGross(double rate, int hours);
double calcTax(double gross, double taxRate);
Define the calcTax function so that all three taxes can be calculated
by calling the same function three times:
fica = calcTax(gross, FICA_RATE);
federal = calcTax(gross, FEDERAL_RATE);
state = calcTax(gross, STATE_RATE);
Use these cases to test your program:
Case # Rate Worked Case # Rate Worked
------ ----- ---- ------ ----- ----
1 12.50 40 2 15.00 45
Sample Output:
P05 - Juan Marquez TR 1:00pm
Enter a value between $10 and $15.00 for the hourly rate: 12.50
Enter a value between 1 and 50 for the hours worked: 40
Hourly Rate: 12.50
Hours Worked: 40
Gross Pay: 500.00
FICA Tax: 30.00 at 0.06
Federal Tax: 75.00 at 0.15
State Tax: 25.00 at 0.05
Union Dues: 10.00
Net Pay: 360.00
Net Hourly: 9.00
Thank you!
Press any key to continue
P05 - Juan Marquez TR 1:00pm
Enter a value between $10 and $15.00 for the hourly rate: 15
Enter a value between 1 and 50 for the hours worked: 45
Hourly Rate: 15.00
Hours Worked: 45
Gross Pay: 712.50
FICA Tax: 42.75 at 0.06
Federal Tax: 106.88 at 0.15
State Tax: 35.63 at 0.05
Union Dues: 10.00
Net Pay: 517.25
Net Hourly: 11.49
Thank you!
Press any key to continue