//Jeremy Huang   CS1A   Practicum
//
/******************************************************************************
 * CALCULATE WEEKLY PAYROLL REPORT
 * 
 ******************************************************************************
 * This program calculates a weekly payroll report based on input
 * of the gross pay, state tax, federal tax, FICA withholdings, and employee
 * number of each employee.
 * 
 * ****************************************************************************
 * INPUTS
 * employee_num             : the id of the employee
 * grossPay                 : gross pay of the employee
 * stateTax                 : state tax for the employee
 * federalTax               : federal tax for the employee
 * ficawithholdings         : FICA withholdings for the employee
 * 
 * OUTPUTS
 * gross_pay_total          : gross pay total for all employees
 * state_tax_total          : state tax total for all employees
 * federal_tax_total        : federal tax total for all employees
 * fica_withholdings_total  : FICA withholdings total for all employees
 * netPay                   : the net pay for all employees
 ******************************************************************************/
 
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
	//Initializing variables
	int employee_num;
	double grossPay;
	double stateTax;
	double federalTax;
	double fica_withholdings;
	double netPay;
 
	double gross_pay_total = 0;
	double state_tax_total = 0;
	double federal_tax_total = 0;
	double fica_withholdings_total = 0;
 
	cout<<"Please enter the employee number (Enter 0 to terminate): "<<endl;
	cin>>employee_num;
 
	//Loop, input
	while (employee_num != 0)
	{
	cout<<"Please enter the gross pay for employee "<<employee_num<<": "<<endl;
	cin>>grossPay;
	cout<<"Please enter the state tax for employee "<<employee_num<<": "<<endl;
	cin>>stateTax;
	cout<<"Please enter the federal tax for employee "<<employee_num<<": "<<endl;
	cin>>federalTax;
	cout<<"Please enter the FICA withholdings for employee "
	<<employee_num<<": "<<endl;
	cin>>fica_withholdings;
	cout<<"Please enter the employee number (Enter 0 to terminate): "<<endl;
	cin>>employee_num;
 
	//Accumulators
	gross_pay_total+=grossPay;
	state_tax_total+=stateTax;
	federal_tax_total+=federalTax;
	fica_withholdings_total+=fica_withholdings;
	}
 
	//Net pay calculation
	netPay = gross_pay_total - 
	(state_tax_total+federal_tax_total+fica_withholdings_total);
 
	//Formatting output
	cout<<showpoint<<fixed<<setprecision(2)<<endl<<endl;
	cout<<"Gross Pay"<<setw(14)<<"State Tax"<<setw(16)<<"Federal Tax"
	<<setw(22)<<"FICA Withholdings"<<setw(12)<<"Net Pay"<<endl;
	cout<<gross_pay_total<<setw(13)<<state_tax_total<<setw(15)
	<<federal_tax_total <<setw(15)<<fica_withholdings_total
	<<setw(23)<<netPay<<endl;
 
	return 0;
}