// Practicum 1: Ryan Shahriyarpour CS1A Carl Argila MCS Building
/*****************************
*
* Compute Weekly Payroll
*
* ***************************
*
* This program prompts the user for an employee number, gross pay,
* state tax, federal tax, and FICA withholdings for each employee.
* The loop will repeat until the sentinel value 0 is entered for the
* employee number.
*
* After all data is entered, the program will display a weekly payroll
* report on two lines: a line of column headers followed by a line
* of totals for gross pay, state tax, federal tax, FICA
* withholdings, and net pay for all employees.
*
* Net Pay Formula:
* Net Pay = Gross Pay - (State Tax + Federal Tax + FICA Withholdings)
* ****************************
*
* Variables:
*
* grossPay = gross pay
* stateTax = state tax
* fedTax = federal tax
* fica = FICA withholdings
* totalGross = total gross payment
* totalState = total state tax paid
* totalFed = total federal tax paid
* totalFica = total FICA withholdings
* netPay = total net payment
*
*
* ****************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
//declare the variables
int empNum;
double grossPay, stateTax, fedTax, fica;
double totalGross = 0, totalState = 0, totalFed = 0, totalFica = 0;
double netPay;
//read the employee numbers until sentinal value 0 is entered
cout << "Enter employee number (0 to quit): ";
cin >> empNum;
while (empNum != 0)
{
cout << "Enter your gross pay: ";
cin >> grossPay;
cout << "Enter the state tax: ";
cin >> stateTax;
cout << "Enter the federal tax: ";
cin >> fedTax;
cout << "Enter FICA withholdings: ";
cin >> fica;
totalGross = totalGross + grossPay;
totalState = totalState + stateTax;
totalFed = totalFed + fedTax;
totalFica = totalFica + fica;
cout << "Enter employee number (0 to quit): " << endl;
cin >> empNum;
}
//Calculate total net pay with formula
netPay = totalGross - (totalState + totalFed + totalFica);
//Display the payroll using 2 lines
cout << " " << endl;
cout << "Weekly Payroll Report";
cout << fixed << setprecision(2) << endl;
cout << left << setw(14) << "Gross Pay"
<< setw(14) << "State Tax"
<< setw(14) << "Federal Tax"
<< setw(14) << "FICA"
<< setw(14) << "Net Pay" << endl;
cout << left << setw(14) << totalGross
<< setw(14) << totalState
<< setw(14) << totalFed
<< setw(14) << totalFica
<< setw(14) << netPay << endl;
return 0;
}