1 /*C++ How to Program, 9/E, by Paul Deitel & Harvey Deitel.
3 Solution of exercise 4.16:
4 (Salary Calculator) Develop a C++ program that uses a while statement to
5 determine the gross pay for each of several employees. The company pays
6 "straight time" for the first 40 hours worked by each employee and pays
7 "time-and-a-half" for all hours worked in excess of 40 hours. You are given a
8 list of the employees of the company, the number of hours each employee worked
9 last week and the hourly rate of each employee. Your program should input this
10 information for each employee and should determine and display the employee's
13 Enter hours worked (-1 to end): 39
14 Enter hourly rate of the employee ($00.00): 10.00
17 Enter hours worked (-1 to end): 40
18 Enter hourly rate of the employee ($00.00): 10.00
21 Enter hours worked (-1 to end): 41
22 Enter hourly rate of the employee ($00.00): 10.00
25 Enter hours worked (-1 to end): -1
27 Written by Juan Carlos Moreno (jcmhsoftware@gmail.com), 2022-12-22.*/
36 int hours
; //Number of hours worked
37 double rate
; //Hourly rate of the worker
38 double salary
; //Employee's gross pay
42 cout
<< "Enter # of hours worked (-1 to end): ";
47 cout
<< "Enter hourly rate of the employee ($00.00): ";
50 //The company pays "straight time"
55 //The company pays "time-and-a-half"
58 salary
= 40*rate
+ 1.5*(hours
- 40)*rate
;
60 cout
<< setprecision(2) << fixed
;
61 cout
<< "Salary is $" << salary
<< endl
<< endl
;