fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. int employeeNum;
  8. float grossPay;
  9. float stateTax;
  10. float federalTax;
  11. float FICA;
  12. float netPay;
  13. float totalstateTax;
  14. float totalfederalTax;
  15. float totalFICA;
  16. float totalgrossPay;
  17. float totalnetPay;
  18.  
  19.  
  20. cout << "Enter a employee number. Press 0 to exit\n";
  21. cin >> employeeNum;
  22.  
  23. totalgrossPay=0;
  24. totalstateTax=0;
  25. totalfederalTax=0;
  26. totalFICA=0;
  27. totalnetPay=0;
  28.  
  29. cout << fixed << setprecision(2);
  30. while (employeeNum !=0)
  31. {
  32.  
  33. cout << "Enter gross pay for the employee.\n";
  34. cin >> grossPay;
  35.  
  36. while (grossPay < 0)
  37. {
  38. cout << "Only enter positive number for gross pay.\n";
  39. cin >> grossPay;
  40. }
  41.  
  42. cout << "Enter State Tax for the employee.\n";
  43. cin >> stateTax;
  44.  
  45. if ( stateTax > grossPay || stateTax < 0 )
  46. {
  47. cout << "Only enter positive value of State tax less than gross pay\n";
  48. cin >> stateTax;
  49. }
  50.  
  51. cout << "Enter Federal Tax for the employee.\n";
  52. cin >> federalTax;
  53.  
  54. if ( federalTax > grossPay || federalTax < 0)
  55. {
  56. cout << "Only enter value of Federal tax less than gross pay\n";
  57. cin >> federalTax;
  58. }
  59.  
  60. cout << "Enter FICA withholdings for the employee.\n";
  61. cin >> FICA;
  62.  
  63. if ( FICA > grossPay || FICA < 0)
  64. {
  65. cout << "Only enter positive value of FICA withholdings less than gross pay\n";
  66. cin >> FICA;
  67. }
  68.  
  69. if ( stateTax + federalTax + FICA > grossPay)
  70. {
  71. cout << "Enter stateTax , federal tax & FICA values again\n";
  72. cout << "State Tax\n";
  73. cin >> stateTax;
  74. cout << "FederalTax Tax\n";
  75. cin >> federalTax;
  76. cout << "FICA witholdingds\n";
  77. cin >> FICA;
  78. }
  79.  
  80. netPay = grossPay - stateTax - federalTax - FICA;
  81.  
  82. totalgrossPay += grossPay;
  83. totalstateTax += stateTax;
  84. totalfederalTax += federalTax;
  85. totalFICA += FICA;
  86. totalnetPay += netPay;
  87.  
  88. cout << "Gross Pay for Employee Num : " << employeeNum << " is $" << netPay << endl;
  89.  
  90. cout << "Enter a employee number. Press 0 to exit\n";
  91. cin >> employeeNum;
  92. }
  93.  
  94. cout << "Weekly Payroll Report\n";
  95. cout << "______________________________\n";
  96. cout << "Total Gross Pay = $" << totalgrossPay << endl;
  97. cout << "Total State Tax = $" << totalstateTax << endl;
  98. cout << "Total Federal Tax = $" << totalfederalTax << endl;
  99. cout << "Total FICA withholdings = $" << totalFICA << endl;
  100. cout << "Total Net Pay = $" << totalnetPay << endl;
  101.  
  102.  
  103. return 0;
  104. }
Success #stdin #stdout 0s 5264KB
stdin
8783
1800
20
30
50
46547
1800
20
30
50
0
stdout
Enter a employee number. Press 0 to exit
Enter gross pay for the employee.
Enter State Tax for the employee.
Enter Federal Tax for the employee.
Enter FICA withholdings for the employee.
Gross Pay for Employee Num : 8783 is $1700.00
Enter a employee number. Press 0 to exit
Enter gross pay for the employee.
Enter State Tax for the employee.
Enter Federal Tax for the employee.
Enter FICA withholdings for the employee.
Gross Pay for Employee Num : 46547 is $1700.00
Enter a employee number. Press 0 to exit
Weekly Payroll Report
______________________________
Total Gross Pay = $3600.00
Total State Tax = $40.00
Total Federal Tax = $60.00
Total FICA withholdings = $100.00
Total Net Pay = $3400.00