Advertisement
Guest User

4.

a guest
Dec 6th, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. const int STD_HRS = 40;
  6. const float OVERTIME_MULT = 1.5;
  7.  
  8. int main()
  9. {
  10.  
  11. cout << setprecision(2);
  12. float hours, rate;
  13. cout << "Enter hours worked: ";
  14. cin >> hours;
  15. cout << "Enter rate: ";
  16. cin >> rate;
  17. float regular, overtime;
  18. if ( hours == STD_HRS )
  19. {
  20. regular = hours * rate;
  21. overtime = 0.0;
  22. }
  23. else
  24. {
  25. regular = STD_HRS * rate;
  26. overtime = (hours - STD_HRS) * OVERTIME_MULT;
  27. }
  28. float pay;
  29. pay = regular + overtime;
  30. cout << "Pay: $" << pay << endl;
  31. return 0;
  32. }
  33.  
  34. OUTPUT:
  35. Enter hours worked: 40
  36. Enter rate: 8
  37. Pay: $320.00
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement