Question: Write a program that will calculate a person's weekly gross pay (gross pay is pay before taxes). A person who is paid by the hour

Write a program that will calculate a person's weekly gross pay (gross pay is pay before taxes).

A person who is paid by the hour receives weekly gross pay based on their pay rate ($/hr.) multiplied by the number of hours worked. In addition, if the person works more than 40 hours, they are paid "time-and-a-half" (1.5x) for hours in excess of 40 hours.

The program will ask the user to enter the pay rate of the person (as a double), followed by the number of hours worked (as a double), and will display the weekly gross pay.

(1) Using a loop, continue to ask for additional pay rates (and hours) until a pay rate of zero is entered. (3 pts)

Ex:

Enter the pay rate (0 to quit): $10.55 Enter the number of hours worked: 12.5 Pay: $131.88 Enter the pay rate (0 to quit): $0 

Ex:

Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 41 Pay: $415.00 Enter the pay rate (0 to quit): $0 

Ex:

Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 41 Pay: $415.00 Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 40 Pay: $400.00 Enter the pay rate (0 to quit): $0 

(2) Using loops, validate the pay rate is not negative. The validate messages are indented 3 spaces. (3 pts)

Ex:

Enter the pay rate (0 to quit): $-1 Pay rate must be positive. Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $0 

Ex:

Enter the pay rate (0 to quit): $-1 Pay rate must be positive. Enter the pay rate (0 to quit): $-5 Pay rate must be positive. Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $0 

Ex:

Enter the pay rate (0 to quit): $-1 Pay rate must be positive. Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $-5 Pay rate must be positive. Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 40 Pay: $400.00 Enter the pay rate (0 to quit): $0 

(3) Using loops, validate the number of hours worked is greater than zero. The validation messages are indented 3 spaces. (2 pts)

Ex:

Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 0 Hours worked must be positive. Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 41 Pay: $415.00 Enter the pay rate (0 to quit): $0 

Ex:

Enter the pay rate (0 to quit): $10 Enter the number of hours worked: -1 Hours worked must be positive. Enter the number of hours worked: -5 Hours worked must be positive. Enter the number of hours worked: 12 Pay: $120.00 Enter the pay rate (0 to quit): $10 Enter the number of hours worked: 41 Pay: $415.00 Enter the pay rate (0 to quit): $0 

and here is my code i need help please

#include #include int main(void) { double hoursPay = 0.0; double payRate = 0.0; double pay = 0.0; /* Type your code here. */

printf("Enter the pay rate (0 to quit): $"); while (payRate < 1) { if (payRate <1) { printf("Pay rate must be positive."); } else { printf("Enter the number of hours worked: ");

} } for (hoursPay <1) { if (hoursPay<1) { printf("Hours worked must be positive.");

}

else { pay = payRate * hoursPay; printf("Pay: $%.2lf", pay); } }

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!