Develop a C++ program that uses a while statement to determine the gross pay for each of several employees. The company pays “straight time” for the first 40 hours worked by each employee and pays “time-and-a-half” for all hours worked in excess of 40 hours. You are given a list of the employees of the company, the number of hours each employee worked last week and the hourly rate of each
employee. Your program should input this information for each employee and should determine and display the employee’s gross pay.
Enter hours worked (-1 to end): 39
Enter hourly rate of the employee ($00.00): 10.00
Salary is $390.00
Enter hours worked (-1 to end): 40
Enter hourly rate of the employee ($00.00): 10.00
Salary is $400.00
Enter hours worked (-1 to end): 41
Enter hourly rate of the employee ($00.00): 10.00
Salary is $415.00
Enter hours worked (-1 to end): -1
Top:
Determine the gross pay for an arbitrary number of employees
First refinement:
For each employee
Input the hours worked
Input the hourly rate
Calculate and display worker’s gross pay
Second refinement:
Prompt the user for the hours worked for the first employee
Input the hours worked for the first employee
While the sentinel value (-1) has not been entered for the hours
Prompt the user for the employee’s hourly rate
Input the employee’s hourly rate
If the hours input is less than or equal to 40
Calculate gross pay by multiplying hours worked by hourly rate
Else
Calculate gross pay by multiplying hours worked above forty by 1.5 times
the hourly rate and adding 40 hours worked by the hourly rate
Display the employee’s gross pay.
Input the hours worked for the next employee
```
// Calculating wages.
#include
#include
using namespace std;
int main()
{
double hours; // total hours worked
double rate; // hourly pay rate
double salary; // gross pay
// processing phase
// get first employee's hours worked
cout << "Enter hours worked (-1 to end): ";
cin >> hours;
// set floating-point number format
cout << fixed << setprecision( 2 );
// loop until sentinel value read from user
while ( hours != -1.0 )
{
// get hourly rate
cout << "Enter hourly rate of the employee ($00.00): ";
cin >> rate;
// if employee worked less than 40 hours
if ( hours <= 40 )
salary = hours * rate;
else // else, compute "time-and-a-half" pay
salary = 40.0 * rate + ( hours - 40.0 ) * rate * 1.5;
cout << "Salary is $" << salary; // display gross pay
// prompt for next employee's data
cout << "\n\nEnter hours worked (-1 to end): ";
cin >> hours;
} // end while
} // end main
```
Enter hours worked (-1 to end): 39
Enter hourly rate of the employee ($00.00): 10.00
Salary is $390.00
Enter hours worked (-1 to end): 40
Enter hourly rate of the employee ($00.00): 10.00
Salary is $400.00
Enter hours worked (-1 to end): 41
Enter hourly rate of the employee ($00.00): 10.00
Salary is $415.00
Enter hours worked (-1 to end): -1
You might also like to view...
Answer the following statements true (T) or false (F)
1. The amount of memory used by an array depends on the array's data type and the number of elements in the array. 2. An array initialization must be all on one line. 3. When you pass an array as an argument to a function, the function can modify the contents of the array. 4. C++ limits the number of array dimensions to two. 5. If you attempt to store data past an array's boundaries, it is guaranteed to cause a compiler error.
Modify the cdh function to filter out multiple occurrences of the same directory. The new function should work as shown
$ cdh –l 0 /users/pat $ cdh $ cdh $ cdh –l 0 /users/pat $
Discuss at length the options for controlling label placement on forms.
What will be an ideal response?
In the following function, the value_if_error would be:
=IFERROR(VLOOKUP(A25,catalog,4,FALSE),"") A) 4. B) A25. C) "". D) catalog.