Advertisement
Guest User

sd

a guest
Oct 17th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. /**
  2. * CIS 22A
  3. * Wages Lab - lab1.cpp
  4. * ~ Calculates wages and amount of taxes
  5. *
  6. * @author Minhduc Cao
  7. * @version 1.1
  8. * @since 10.17.17
  9. */
  10. #include <iostream>
  11. #include <iomanip>
  12.  
  13. using namespace std;
  14.  
  15. double hours, dependents, grossPay, netPay;
  16. double securityTax, incomeTax, stateTax, insuranceTax;
  17. double const unionTax = 10;
  18. double const payrate = 16.78;
  19.  
  20. // Calculates the gross pay amount
  21. void calculateGross() {
  22. if (hours <= 40) {
  23. grossPay = hours * payrate;
  24. }
  25. else {
  26. grossPay = hours * payrate;
  27. double overtimeHours = hours - 40;
  28. grossPay += overtimeHours * payrate * 1.5;
  29. }
  30. }
  31.  
  32. // Calculates the net pay amount and any other tax amounts
  33. void calculateNet() {
  34. netPay = grossPay;
  35.  
  36. securityTax = netPay * 0.06;
  37. netPay -= securityTax;
  38.  
  39. incomeTax = netPay * 0.14;
  40. netPay -= incomeTax;
  41.  
  42. stateTax = netPay * 0.05;
  43. netPay -= stateTax;
  44.  
  45. netPay -= unionTax;
  46.  
  47. if (dependents >= 3)
  48. {
  49. insuranceTax = 35;
  50. netPay -= insuranceTax;
  51. }
  52. }
  53.  
  54. // Asks the user for # of hours and # of dependents, calculates the gross and net pay
  55. // Displays the pay amounts and tax amounts
  56. int main() {
  57. cout << "Enter the # of hours worked: " << endl;
  58. cin >> hours;
  59.  
  60. cout << "Enter the # of dependents: " << endl;
  61. cin >> dependents;
  62.  
  63. calculateGross();
  64. calculateNet();
  65.  
  66. // Sets the precision of data values to properly represent money values
  67. cout << fixed;
  68. cout << setprecision(2);
  69.  
  70. cout << endl << "Gross Pay: $" << grossPay << endl;
  71. cout << "Social Security Tax: $" << securityTax << endl;
  72. cout << "Income Tax: $" << incomeTax << endl;
  73. cout << "State Income Tax: $" << stateTax << endl;
  74. cout << "Union Tax: $" << unionTax << endl;
  75. cout << "Insurance Tax: $" << insuranceTax << endl;
  76. cout << "-----------------------" << endl << "Net Pay: $" << netPay << endl;
  77. return 0;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement