//Charlotte Davies-Kiernan CS1A First Practicum
//
/******************************************************************************
*
* Compute Weekly Payroll Totals
* ____________________________________________________________________________
* This program will compute the weekly payroll report of a number of employees.
* Consisting of totals for gross pay, state tax, federal tax, FICA
* withholdings, and net pay, for all employees.
*
* Formula used:
* Net pay = gross pay - (state tax + federal tax + FICA withholdings)
* ____________________________________________________________________________
* Input
* employeeNumber //Identifiction number for each employee
* grossPay //Pay for each employee
* stateTax //State tax for each employee
* federalTax //Federal tax for each employee
* ficaWithholdings //FICA withholdings for each employee
* Output
* total_gross_pay //Total pay for all employees
* total_state_tax //Total state tax for all employees
* total_federal_tax //Total federal tax for all employees
* total_fica //Total FICA withholdings for all employees
* netPay //Total net pay for all employees taking into account taxes
*****************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
//Data Dictionary
int employeeNumber; //INPUT - Identifiction number for each employee
float grossPay; //INPUT - Pay for each employee
float stateTax; //INPUT - State tax for each employee
float federalTax; //INPUT - Federal tax for each employee
float ficaWithholdings; //INPUT - FICA withholdings for each employee
float total_gross_pay; //OUPUT - Total pay for all employees
float total_state_tax; //OUTPUT - Total state tax for all employees
float total_federal_tax; //OUTPUT - Total federal tax for all employees
float total_fica; //OUTPUT - Total FICA withholdings for all employees
float netPay; //OUTPUT - Total net pay for all employees taking into account taxes
total_gross_pay = 0;
total_state_tax = 0;
total_federal_tax = 0;
total_fica = 0;
//Prompt User in Order to Calculate
do {
cout << "Please enter the employee number: " << endl;
cin >> employeeNumber;
if(employeeNumber != 0){
cout << "Please enter the gross pay for this employee (no commas!): " << endl;
cin >> grossPay;
total_gross_pay += grossPay;
total_gross_pay = total_gross_pay;
cout << "Please enter the state tax for this employee: " << endl;
cin >> stateTax;
total_state_tax += stateTax;
total_state_tax = total_state_tax;
cout << "Please enter the federal tax for this employee: " << endl;
cin >> federalTax;
total_federal_tax += federalTax;
total_federal_tax = total_federal_tax;
cout << "Please enter the FICA withholdings for this employee: " << endl;
cin >> ficaWithholdings;
total_fica += ficaWithholdings;
total_fica = total_fica;
cout << "If you wish to stop here put 0 for employee number!" << endl;
}
}
while (employeeNumber != 0);
if(employeeNumber == 0){
cout << "0 has been entered now calculating totals... " << endl;}
//Calculate Net Pay
netPay = total_gross_pay - (total_state_tax + total_federal_tax + total_fica);
//Display Totals
cout << setw(9) << "Total: Gross Pay" << setw(12) << "State Tax " ;
cout << setw(13) << "Federal Tax" << setw(20) << "FICA Withholdings";
cout << setw(13) << "Net Pay" << endl;
cout << setw(9) << "$" << total_gross_pay << setw(6) << "$" << total_state_tax;
cout << setw(7) << "$" << total_federal_tax << setw(10) << "$" << total_fica;
cout << setw(13) << "$" << netPay << endl;
return 0;
}