C++ Programming Assignment; Run the program and enter salaries that less than $
ID: 3669328 • Letter: C
Question
C++ Programming Assignment; Run the program and enter salaries that less than $ 80.000.00. and also salaries that are greater than $80,000.00. Program specifications Building on programming assignment 3, modify your program so that the user can process payroll for as many employees as he/she desires. You need to use a counter controlled loop that executes as many times as the user wishes based on his response to how many paychecks he/she wish to process . The output of your program should be well designed and display the payroll for all employees as shown below. Review Guide Program Dynamic Loops posted as guide. Your program should display the following on the monitor : How many Paychecks do you want to process? For example let’s say the user entered 4. Your program should process paycheck for 4 employees. So based on user request your program should process that many paychecks. After user entered his/her response then the program should display: Enter Salary for employee #1 After payroll for employee #1 has been processed and the result has been displayed the program should display Enter Salary for Employee # 2 and continue processing payroll until all paychecks has been processed based on the number that user has entered. HINT: Review the Dynamic Loops Programming Guide and I am sure you can code this program. The output of your program should look like the following. For example if the user has entered 4 as number of employees then your program should display payroll information for all 4 employees as follows: Payroll for Employee #1 Employee Gross income $....... Federal Tax deducted $... State Tax Deducted $ FICA Tax Deducted $.... Net Pay is: $........ Payroll for Employee# 2 …….. And display all information for all employees as the user has requested
Explanation / Answer
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
int EmplNum;
double GrossPay,
StateTax,
FedTax,
FICA,
Wth,
NetPay,
TotGrossPay = 0,
TotStateTax = 0,
TotFedTax = 0,
TotFICA = 0,
TotNetPay = 0;
cout << " This program generates a weekly payroll Report. "
<< "Enter employee number: ";
cin >> EmplNum;
while (EmplNum != 0)
{
do
{
cout << "Enter gross pay: ";
cin >> GrossPay;
while (GrossPay < 0)
{
cout << "Error! Gross pay must be a positive integer."
<< "Enter gross pay: ";
cin >> GrossPay;
}
cout << "Enter state tax: ";
cin >> StateTax;
while (StateTax < 0)
{
cout << "Error! state tax must be a positive integer. ";
cout << "Enter state tax: ";
cin >> StateTax;
}
cout << "Enter federal tax: ";
cin >> FedTax;
while (FedTax < 0)
{
cout << "Error! federal tax must be a positive integer. ";
cout << "Enter federal tax: ";
cin >> FedTax;
}
cout << "Enter FICA withholdings: ";
cin >> FICA;
while (FICA < 0)
{
cout << "Error! FICA withholdings must be a positive integer. ";
cout << "Enter FICA withholdings: ";
cin >> FICA;
}
Wth = (StateTax + FedTax + FICA);
if (Wth > GrossPay)
{
cout << "Error! Invaild data. "
<< "Total withholdings can not be greater than gross pay."
<< " Please Enter data for employee number: "
<< EmplNum << endl;
}
} while (Wth > GrossPay);
TotGrossPay += GrossPay;
TotStateTax += StateTax;
TotFedTax += FedTax;
TotFICA += FICA;
NetPay = GrossPay - Wth;
TotNetPay += NetPay;
cout << "Enter employee number: ";
cin >> EmplNum;
}
cout << " Weekly Payroll Report "
<< "--------------------------------- ";
cout << right << fixed << showpoint << setprecision(2);
cout << "Total Gross Pay : $" << setw(8) << TotGrossPay << endl;
cout << "Total State Tax : $" << setw(8) << TotStateTax << endl;
cout << "Total Federal Tax : $" << setw(8) << TotFedTax << endl;
cout << "Total FICA : $" << setw(8) << TotFICA << endl;
cout << "Total Net Pay : $" << setw(8) << TotNetPay << endl << endl;
return 0;
}
sample output
This program generates a weekly payroll Report.
Enter employee number: 1
Enter gross pay: 80000
Enter state tax: 30
Enter federal tax: 25
Enter FICA withholdings: 10
Enter employee number: 2
Enter gross pay: 75000
Enter state tax: 25
Enter federal tax: 20
Enter FICA withholdings: 5
Enter employee number: 0
Weekly Payroll Report
---------------------------------
Total Gross Pay : $155000.00
Total State Tax : $ 55.00
Total Federal Tax : $ 45.00
Total FICA : $ 15.00
Total Net Pay : $154885.00
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.