Problem 3: Payroll System The Pine Furniture Company has recently hired you to h
ID: 3681792 • Letter: P
Question
Problem 3: Payroll System The Pine Furniture Company has recently hired you to help them convert their antiquated payroll system to a computer-based model. They asked you to write a program that will print a one-week pay report for their employees. The values for the different salary deduction are given in the following table
Item
Rate
Federal withholding tax
State withholding tax
Hospitalization
Union dues
18%
4.5%
$25.65
$7.85
Each line of input will contain
Employee initials Number of hours worked Hourly rate
You should declare each deduction percentage as a named constant.
Your output should display a report for the employee as in the following
To stop enter XX 1 1
Item
Rate
Federal withholding tax
State withholding tax
Hospitalization
Union dues
18%
4.5%
$25.65
$7.85
Explanation / Answer
#include <iostream>
using namespace std;
int main() {
//Set cout
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
//Get User input
double hoursWorked;
int dependents;
cout << "Enter hours worked: ";
cin >> hoursWorked;
cout << "Enter number of dependents: ";
cin >> dependents;
//Calculate total pay.
const double hourPay = 16.78;
double totalPay;
if(hoursWorked <= 40.0) {
totalPay = hourPay * hoursWorked;
} else {
double overTime = hoursWorked - 40.0;
totalPay = ((hoursWorked - overTime) + (overTime * 1.5)) * hourPay;
cout << "Overtime worked: " << overTime << endl;
}
//Calculate withhelds
double netPay = totalPay;
double socialSecurity = totalPay * 0.06;
netPay -= socialSecurity;
double federalIncomeTax = totalPay * 0.18;
netPay -= federalIncomeTax;
double stateIncomeTax = totalPay * 0.045;
netPay -= stateIncomeTax;
double unionDues = 7.85;
netPay -= unionDues;
double extraHealthInsurance = 0.0;
if(dependents >= 3) {
extraHealthInsurance = 25.65;
}
netPay -= extraHealthInsurance;
//Print out Paycheck
cout << endl;
cout << "Total Pay: $" << totalPay << endl;
cout << "Withhelds ";
cout << " Social Security: $" << socialSecurity << endl;
cout << " Federal Income Tax: $" << federalIncomeTax << endl;
cout << " State Income Tax: $" << stateIncomeTax << endl;
cout << " Union Dues: $" << unionDues << endl;
cout << " Extra Health Insurance: $" << extraHealthInsurance << endl;
cout << "Net Pay: $" << netPay;
return 0;
}
sample output
Enter hours worked: 12
Enter number of dependents: 3
Total Pay: $201.36
Withhelds
Social Security: $12.08
Federal Income Tax: $36.24
State Income Tax: $9.06
Union Dues: $7.85
Extra Health Insurance: $25.65
Net Pay: $110.47
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.