fork download
  1. // Timothy Price CS1A Practicum 1
  2. /*******************************************************************************
  3.  * Calculate report
  4.  *
  5.  * This program receives values for identification and income and creates a
  6.  * report of the calculated payroll.
  7.  *
  8.  * Inputs:
  9.  * employee number
  10.  * gross pay
  11.  * state tax
  12.  * federal tax
  13.  * FICA withholdings
  14.  *
  15.  * Outputs:
  16.  * displayable report
  17.  * net pay calculation
  18.  ******************************************************************************/
  19.  
  20. #include <iostream>
  21. #include <iomanip>
  22. #include <cmath>
  23.  
  24. using namespace std;
  25.  
  26. int main() {
  27.  
  28. // Data dictionary
  29. int employee;
  30. float federal;
  31. float fedtotal = 0;
  32. float fica;
  33. float ficatotal = 0;
  34. float gross;
  35. float grosstotal = 0;
  36. float net_pay;
  37. float net_total = 0;
  38. float state;
  39. float statetotal = 0;
  40.  
  41. // Initial employee input
  42. cout << "Enter employee number: ";
  43. cin >> employee;
  44. cout << employee << endl;
  45.  
  46. // Loop to receive inputs, with input confirmation
  47. while(employee != 0){
  48. cout << "Enter the gross pay for this employee: ";
  49. cin >> gross;
  50. cout << "$" << gross << endl;
  51. cout << "Enter the state tax: ";
  52. cin >> state;
  53. cout << "$" << state << endl;
  54. cout << "Enter the federal tax: ";
  55. cin >> federal;
  56. cout << "$" << federal << endl;
  57. cout << "Enter the FICA withholdings: ";
  58. cin >> fica;
  59. cout << "$" << fica << endl;
  60. cout << "Enter another employee number or '0' to stop: ";
  61. cin >> employee;
  62. cout << employee << endl;
  63.  
  64. // total calculations, adding each input per loop iteration
  65. net_pay = (gross) - (state + federal + fica);
  66. fedtotal += federal;
  67. ficatotal += fica;
  68. grosstotal += gross;
  69. net_total += net_pay;
  70. statetotal += state;
  71. }
  72. // Completion confirmation
  73. cout << "Entry complete." << endl << endl;
  74.  
  75. // Display report
  76. cout << "\t\t\t\t----- WEEKLY PAYROLL REPORT -----" << endl;
  77. cout << "-----------------------------------------------------------------";
  78. cout << "------------" << endl;
  79. cout << "Gross pay\tState Tax\tFederal Tax\tFICA withholding\t";
  80. cout << "Net Pay ";
  81. cout << "-----------------------------------------------------------------";
  82. cout << "------------" << endl;
  83. cout << fixed << setprecision(2);
  84. cout << "$" << grosstotal << "\t$" << statetotal << "\t\t$" << fedtotal;
  85. cout << "\t$" << ficatotal << "\t\t\t\t$" << net_total;
  86.  
  87. return 0;
  88. }
Success #stdin #stdout 0.01s 5324KB
stdin
238621
1386.22
103.12
208.5
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
Enter employee number: 238621
Enter the gross pay for this employee: $1386.22
Enter the state tax: $103.12
Enter the federal tax: $208.5
Enter the FICA withholdings: $125
Enter another employee number or '0' to stop: 513782
Enter the gross pay for this employee: $2508
Enter the state tax: $152.33
Enter the federal tax: $301.19
Enter the FICA withholdings: $175
Enter another employee number or '0' to stop: 312423
Enter the gross pay for this employee: $1975.66
Enter the state tax: $143.78
Enter the federal tax: $298.11
Enter the FICA withholdings: $168
Enter another employee number or '0' to stop: 432152
Enter the gross pay for this employee: $980.55
Enter the state tax: $76.23
Enter the federal tax: $88.54
Enter the FICA withholdings: $98
Enter another employee number or '0' to stop: 601932
Enter the gross pay for this employee: $2930
Enter the state tax: $203.94
Enter the federal tax: $350.25
Enter the FICA withholdings: $200
Enter another employee number or '0' to stop: 0
Entry complete.

				----- WEEKLY PAYROLL REPORT -----
-----------------------------------------------------------------------------
Gross pay	State Tax	Federal Tax	FICA withholding	Net Pay -----------------------------------------------------------------------------
$9780.43	$679.40		$1246.59	$766.00				$7088.44