This is for C++ This program will be used by employees to determine what their w
ID: 3872481 • Letter: T
Question
This is for C++ 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 file 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 - Your Name 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 - Your Name 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 Pseudocode: //function prototypes double inputRate(); int inputHours(); double calcGross(double rate, int hours); double calcTax(double gross, double taxRate); void main() { }//end of main //function definitions double inputRate() { double rate; do { prompt for and get rate }while(rate is not valid) return rate; } int inputHours() { int hours; do { prompt for and get hours }while(hours are not valid) return hours; } double calcGross(double rate, int hours) { double gross; if hours > 40 gross = overtime rate else gross = straight time return gross; } double calcTax(double gross, double taxRate) { double amount; amount = gross * taxRate; return amount; }
Explanation / Answer
#include <iostream>
using namespace std;
double inputRate();
int inputHours();
double calcGross(double rate, int hours);
double calcTax(double gross, double taxRate);
int main()
{
double rate,gross;
int hours;
double FICA_RATE=0.06,FEDERAL_RATE=0.15,STATE_RATE=0.05;
double UNION_DUES = 10.00;
double net_hour,net_pay;
double fica,federal,state;
rate=inputRate();
hours=inputHours();
gross=calcGross(rate,hours);
fica = calcTax(gross, FICA_RATE);
federal = calcTax(gross, FEDERAL_RATE);
state = calcTax(gross, STATE_RATE);
net_pay=gross-(UNION_DUES+fica+federal+state);
net_hour=net_pay/hours;
cout<<" Hourly Rate:"<<rate<<" Hours Worked:"<<hours<<" Gross Pay:"<<gross;
cout<<" FICA Tax:"<<fica<<"at 0.06 Federal Tax:"<<federal<<"at 0.15";
cout<<"State Tax: "<<state<<"at 0.05 Union Dues:"<<UNION_DUES;
cout<<" Net Pay:"<<net_pay<<" Net Hourly:"<<net_hour;
return 0;
}
//function definitions
double inputRate()
{
double rate;
do
{
cout<<"Enter a value between $10 and $15.00 for the hourly rate:";
cin>>rate;
}while(rate<10&&rate>15);
return rate;
}
int inputHours()
{
int hours;
do
{
cout<<" Enter a value between 1 and 50 for the hours worked:";
cin>>hours;
}while(hours>50&&hours<0);
return hours;
}
double calcGross(double rate, int hours)
{
double gross;
if(hours > 40)
gross = rate*hours*1.5;
else
gross = rate*hours;
return gross;
}
double calcTax(double gross, double taxRate)
{
double amount;
amount = gross * taxRate;
return amount;
}
output:
Enter a value between $10 and $15.00 for the hourly rate:
Enter a value between 1 and 50 for the hours worked:
Hourly Rate:12.5
Hours Worked:40
Gross Pay:500
FICA Tax:30at 0.06
Federal Tax:75at 0.15
State Tax: 25at 0.05
Union Dues:10
Net Pay:360
Net Hourly:9
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.