fork(1) download
  1. /*Sam Trivikraman CS1A First Practicum
  2. *
  3. *******************************************************************************
  4. Calculate Weekly Payrole
  5. *******************************************************************************
  6. This program prompts the user for information regarding the employee number,
  7. gross pay, state tax, federal tax, and FICA withholdings. This information is
  8. then used to calculate the total weekly payrole.
  9. *******************************************************************************
  10. INPUT
  11. employee number //the employee number which is given to the specific employee (user input)
  12. gross pay // the base amount of pay that the employee recieves in dollars (user input)
  13. state tax //state tax in dollars (user input)
  14. federal tax //federal tax in dollars(user input)
  15. FICA witholdings //FICA witholdings in dollars (user input)
  16.  
  17. OUTPUT
  18. total gross pay //The total amount of gross pay for all employees in dollars
  19. total state tax //The total amount of state tax for all employees in dollars
  20. total federal tax //The total amount of federal tax for all employees in dollars
  21. total FICA witholdings //The total amount of FICA witholdings for all employees in dollars
  22. net pay //The calculated net pay for all employees in dollars
  23. *******************************************************************************
  24. *
  25. */
  26. #include <iostream>
  27. #include <iomanip>
  28. using namespace std;
  29.  
  30. int main() {
  31.  
  32. //Data Dictionary
  33.  
  34. int employeeNum; //INPUT the employee number associated to the specific employee
  35. float grossPay; //INPUT the gross pay for the employee
  36. float stateTax; //INPUT the state tax for the employee
  37. float fedTax; //INPUT the federal tax for the employee
  38. float ficaWitholdings; //INPUT the FICA Witholdings for the employee
  39. float totalGrossPay; //OUTPUT the total gross pay for all employees
  40. float totalStateTax; //OUTPUT the total state tax for all employees
  41. float totalFedTax; //OUTPUT the total federal tax for all employees
  42. float totalFica; //OUTPUT the total FICA Witholdings for all employees
  43. float netPay; //OUTPUT the calculated net pay for all employees
  44.  
  45.  
  46. //Set staring employee number to 1 to prevent errors
  47. employeeNum = 1;
  48.  
  49. /*As long as the user does not type 0 as the employee number, ask for and
  50. calculate the gross pay, state tax, federal tax, and FICA witholdings */
  51. //If the employee number is 0, terminate the program
  52. while(employeeNum != 0)
  53. {
  54. /*Input: get inputs for the employee number, gross pay, state tax,
  55. federal tax, and FICA witholdings */
  56. cout << "Please enter the employee number (NOTE - write 0 to terminate the program): " << endl;
  57. cin >> employeeNum;
  58. cout << "Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: " << endl;
  59. cin >> grossPay;
  60. cin >> stateTax;
  61. cin >> fedTax;
  62. cin >> ficaWitholdings;
  63.  
  64. //Process (happens every loop iteration)
  65. //Calculate the total gross pay by adding each gross pay amount to it
  66. totalGrossPay += grossPay;
  67. //Calculate the total state tax by adding each state tax amount to it
  68. totalStateTax += stateTax;
  69. //Calculate the total federal tax by adding each federal tax amount to it
  70. totalFedTax += fedTax;
  71. /*Calculate the total FICA witholdings amount by adding each FICA
  72. witholdings amount to it*/
  73. totalFica += ficaWitholdings;
  74. }
  75.  
  76. //Process continued
  77. /*Calculate the net pay using the total gross pay, state tax, federal tax,
  78. and FICA amounts */
  79. netPay = totalGrossPay - (totalStateTax + totalFedTax + totalFica);
  80.  
  81. //Output
  82. /*Create a chart and output the total gross pay, state tax, federal tax,
  83. FICA Witholdings, and net pay amounts */
  84. cout << "\nTotal Gross Pay" << setw(25)<< "Total State Tax" << setw(25) << "Total Federal Tax" << setw(35)<< "Total FICA Witholdings" << setw(25) << "Net Pay" << endl;
  85. cout << "$" << totalGrossPay << setw(25) << "$" << totalStateTax << setw(25) << "$"<< totalFedTax << setw(25) << "$" << totalFica << setw(25) << "$" << netPay << endl;
  86. return 0;
  87. }
Success #stdin #stdout 0s 5308KB
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 (NOTE - write 0 to terminate the program): 
Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: 
Please enter the employee number (NOTE - write 0 to terminate the program): 
Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: 
Please enter the employee number (NOTE - write 0 to terminate the program): 
Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: 
Please enter the employee number (NOTE - write 0 to terminate the program): 
Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: 
Please enter the employee number (NOTE - write 0 to terminate the program): 
Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: 
Please enter the employee number (NOTE - write 0 to terminate the program): 
Please enter the gross pay, state tax, federal tax, and FICA Withholdings for this employee: 

Total Gross Pay          Total State Tax        Total Federal Tax             Total FICA Witholdings                  Net Pay
$12710.4                        $883.34                        $1596.9                        $966                        $9264.19