#include <iostream>
#include <iomanip>
using namespace std;
int main() {
int employeeNum;
float grossPay;
float stateTax;
float federalTax;
float FICA;
float netPay;
float totalstateTax;
float totalfederalTax;
float totalFICA;
float totalgrossPay;
float totalnetPay;
cout << "Enter a employee number. Press 0 to exit\n";
cin >> employeeNum;
totalgrossPay=0;
totalstateTax=0;
totalfederalTax=0;
totalFICA=0;
totalnetPay=0;
cout << fixed << setprecision(2);
while (employeeNum !=0)
{
cout << "Enter gross pay for the employee.\n";
cin >> grossPay;
while (grossPay < 0)
{
cout << "Only enter positive number for gross pay.\n";
cin >> grossPay;
}
cout << "Enter State Tax for the employee.\n";
cin >> stateTax;
if ( stateTax > grossPay || stateTax < 0 )
{
cout << "Only enter positive value of State tax less than gross pay\n";
cin >> stateTax;
}
cout << "Enter Federal Tax for the employee.\n";
cin >> federalTax;
if ( federalTax > grossPay || federalTax < 0)
{
cout << "Only enter value of Federal tax less than gross pay\n";
cin >> federalTax;
}
cout << "Enter FICA withholdings for the employee.\n";
cin >> FICA;
if ( FICA > grossPay || FICA < 0)
{
cout << "Only enter positive value of FICA withholdings less than gross pay\n";
cin >> FICA;
}
if ( stateTax + federalTax + FICA > grossPay)
{
cout << "Enter stateTax , federal tax & FICA values again\n";
cout << "State Tax\n";
cin >> stateTax;
cout << "FederalTax Tax\n";
cin >> federalTax;
cout << "FICA witholdingds\n";
cin >> FICA;
}
netPay = grossPay - stateTax - federalTax - FICA;
totalgrossPay += grossPay;
totalstateTax += stateTax;
totalfederalTax += federalTax;
totalFICA += FICA;
totalnetPay += netPay;
cout << "Gross Pay for Employee Num : " << employeeNum << " is $" << netPay << endl;
cout << "Enter a employee number. Press 0 to exit\n";
cin >> employeeNum;
}
cout << "Weekly Payroll Report\n";
cout << "______________________________\n";
cout << "Total Gross Pay = $" << totalgrossPay << endl;
cout << "Total State Tax = $" << totalstateTax << endl;
cout << "Total Federal Tax = $" << totalfederalTax << endl;
cout << "Total FICA withholdings = $" << totalFICA << endl;
cout << "Total Net Pay = $" << totalnetPay << endl;
return 0;
}