Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5.  
  6. double calcGrossPay(int hours, double rate)
  7. {
  8. double grossPay = 0.0;
  9. double overtimePay = 0.0;
  10.  
  11. if (hours > 40) {
  12. hours = hours - 40;
  13. overtimePay = hours * (rate * 1.5);
  14. }
  15. grossPay = hours*rate + overtimePay;
  16. return grossPay;
  17. }
  18.  
  19. double calcTotal(double current, double pay)
  20. {
  21. double total = 0.0;
  22. total = current + pay;
  23. return total;
  24.  
  25. }
  26.  
  27. int main()
  28. {
  29. int hours = 0;
  30. int employee = 0;
  31. double rate = 0.0;
  32. double current = 0.0;
  33. double totalGrossPay = 0.0;
  34. double pay = 0.0;
  35.  
  36.  
  37. while(1){
  38. employee++;
  39. cout << "Enter Total hours worked for employee " << employee << ", -1 to cancel: " << endl;
  40. cin >> hours;
  41. if(hours==-1)
  42. break;
  43. cout << "Enter rate of pay for this employee: " << endl;
  44. cin >> rate;
  45.  
  46. current = calcGrossPay(hours, rate);
  47. cout << "This employee's gross pay is: $" << current << endl;
  48. totalGrossPay += calcTotal(current, pay);
  49.  
  50. }
  51. cout << "The total gross pay of all " << employee << " employee's is : $" << totalGrossPay << endl;
  52.  
  53.  
  54.  
  55. system("pause");
  56. return 0;
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement