fork download
  1. //Charlotte Davies-Kiernan CS1A First Practicum
  2. //
  3. /******************************************************************************
  4.  *
  5.  * Compute Weekly Payroll Totals
  6.  * ____________________________________________________________________________
  7.  * This program will compute the weekly payroll report of a number of employees.
  8.  * Consisting of totals for gross pay, state tax, federal tax, FICA
  9.  * withholdings, and net pay, for all employees.
  10.  *
  11.  * Formula used:
  12.  * Net pay = gross pay - (state tax + federal tax + FICA withholdings)
  13.  * ____________________________________________________________________________
  14.  * Input
  15.  * employeeNumber //Identifiction number for each employee
  16.  * grossPay //Pay for each employee
  17.  * stateTax //State tax for each employee
  18.  * federalTax //Federal tax for each employee
  19.  * ficaWithholdings //FICA withholdings for each employee
  20.  * Output
  21.  * total_gross_pay //Total pay for all employees
  22.  * total_state_tax //Total state tax for all employees
  23.  * total_federal_tax //Total federal tax for all employees
  24.  * total_fica //Total FICA withholdings for all employees
  25.  * netPay //Total net pay for all employees taking into account taxes
  26.  *****************************************************************************/
  27. #include <iostream>
  28. #include <iomanip>
  29. using namespace std;
  30. int main() {
  31. //Data Dictionary
  32. int employeeNumber; //INPUT - Identifiction number for each employee
  33. float grossPay; //INPUT - Pay for each employee
  34. float stateTax; //INPUT - State tax for each employee
  35. float federalTax; //INPUT - Federal tax for each employee
  36. float ficaWithholdings; //INPUT - FICA withholdings for each employee
  37. float total_gross_pay; //OUPUT - Total pay for all employees
  38. float total_state_tax; //OUTPUT - Total state tax for all employees
  39. float total_federal_tax; //OUTPUT - Total federal tax for all employees
  40. float total_fica; //OUTPUT - Total FICA withholdings for all employees
  41. float netPay; //OUTPUT - Total net pay for all employees taking into account taxes
  42. total_gross_pay = 0;
  43. total_state_tax = 0;
  44. total_federal_tax = 0;
  45. total_fica = 0;
  46. //Prompt User in Order to Calculate
  47. do {
  48. cout << "Please enter the employee number: " << endl;
  49. cin >> employeeNumber;
  50. if(employeeNumber != 0){
  51. cout << "Please enter the gross pay for this employee (no commas!): " << endl;
  52. cin >> grossPay;
  53. total_gross_pay += grossPay;
  54. total_gross_pay = total_gross_pay;
  55. cout << "Please enter the state tax for this employee: " << endl;
  56. cin >> stateTax;
  57. total_state_tax += stateTax;
  58. total_state_tax = total_state_tax;
  59. cout << "Please enter the federal tax for this employee: " << endl;
  60. cin >> federalTax;
  61. total_federal_tax += federalTax;
  62. total_federal_tax = total_federal_tax;
  63. cout << "Please enter the FICA withholdings for this employee: " << endl;
  64. cin >> ficaWithholdings;
  65. total_fica += ficaWithholdings;
  66. total_fica = total_fica;
  67. cout << "If you wish to stop here put 0 for employee number!" << endl;
  68. }
  69. }
  70. while (employeeNumber != 0);
  71. if(employeeNumber == 0){
  72. cout << "0 has been entered now calculating totals... " << endl;}
  73. //Calculate Net Pay
  74. netPay = total_gross_pay - (total_state_tax + total_federal_tax + total_fica);
  75. //Display Totals
  76. cout << setw(9) << "Total: Gross Pay" << setw(12) << "State Tax " ;
  77. cout << setw(13) << "Federal Tax" << setw(20) << "FICA Withholdings";
  78. cout << setw(13) << "Net Pay" << endl;
  79. cout << setw(9) << "$" << total_gross_pay << setw(6) << "$" << total_state_tax;
  80. cout << setw(7) << "$" << total_federal_tax << setw(10) << "$" << total_fica;
  81. cout << setw(13) << "$" << netPay << endl;
  82. return 0;
  83. }
Success #stdin #stdout 0.01s 5288KB
stdin
238621
1386.22
103.12
208.56
125.00
513782
2508.00
152.33
301.19
175.00
312423
1975.66
143.78
298.11
168.00
432152
980.55
76.23
88.54
98.00
601932
2930.00
203.94
350.25
200.00
0
stdout
Please enter the employee number: 
Please enter the gross pay for this employee (no commas!): 
Please enter the state tax for this employee: 
Please enter the federal tax for this employee: 
Please enter the FICA withholdings for this employee: 
If you wish to stop here put 0 for employee number!
Please enter the employee number: 
Please enter the gross pay for this employee (no commas!): 
Please enter the state tax for this employee: 
Please enter the federal tax for this employee: 
Please enter the FICA withholdings for this employee: 
If you wish to stop here put 0 for employee number!
Please enter the employee number: 
Please enter the gross pay for this employee (no commas!): 
Please enter the state tax for this employee: 
Please enter the federal tax for this employee: 
Please enter the FICA withholdings for this employee: 
If you wish to stop here put 0 for employee number!
Please enter the employee number: 
Please enter the gross pay for this employee (no commas!): 
Please enter the state tax for this employee: 
Please enter the federal tax for this employee: 
Please enter the FICA withholdings for this employee: 
If you wish to stop here put 0 for employee number!
Please enter the employee number: 
Please enter the gross pay for this employee (no commas!): 
Please enter the state tax for this employee: 
Please enter the federal tax for this employee: 
Please enter the FICA withholdings for this employee: 
If you wish to stop here put 0 for employee number!
Please enter the employee number: 
0 has been entered now calculating totals... 
Total: Gross Pay  State Tax   Federal Tax   FICA Withholdings      Net Pay
        $9780.43     $679.4      $1246.65         $766            $7088.38