Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

(Salary Calculator) Develop a program that will determine the gross pay for each

ID: 3639014 • Letter: #

Question

(Salary Calculator) Develop a program that will 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’re given a list of the employ- ees 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 deter- mine and display the employee's gross pay. Here is a sample input/output dialog:


Enter # of hours worked (-1 to end): 39 Enter hourly rate of the worker ($00.00): 10.00 Salary is $390.00
Enter # of hours worked (-1 to end): 40 Enter hourly rate of the worker ($00.00): 10.00 Salary is $400.00
Enter # of hours worked (-1 to end): 41 Enter hourly rate of the worker ($00.00): 10.00 Salary is $415.00
Enter # of hours worked (-1 to end): -1

Explanation / Answer

1. you don't need to initialize each variable = 1. you could just put:

double hours;
double rate;
double salary; //this makes it look more clean

2. Always put brackets to make the equations look more organized:

salary = ( (40 * rate) + ( (hours - 40 ) * (rate *1.5) ) ); //40*base rate is calculated and added to hours-40 times the rate*1.5

3. I think this is the main thing that you are asking for. You SHOULD put:

//before return 0;
system ("pause"); //so that the compiler shows output and pauses before it exists

You need to specify where it fails or what error it gives, rather than saying it just fails.