Question: Write a C program to compute a workers pay, based on a rate per hour and number of hours worked. - The program must include

Write a C program to compute a workers pay, based on a rate per hour and number of hours worked.

- The program must include a single function named calculatePay, which does the computations. The function should accept 2 parameters: a rate per hour, and the number of hours worked both of which can be fractional. The function should NOT print anything (you can use print statements for testing if you wish, but those should be deleted or commented out before you turn in the assignment). The function should return the amount to be paid.

Then the main program code should print each persons pay.

Additional details (for the calculation of the pay):

- Up to and including the first 40 hours, should be paid at the regular rate per hour.

- Any additional hours between forty and sixty, should be paid at an overtime rate of one and a half times the rate.

- If the person works more than 60 hours, in additional to all of the above, those hours should be paid at double the rate per hour.

To show that the function works correctly, the main program MUST include three calls the function with the following three sets of data. Verify that you get the given results.

1) Rate of 30, 20 hours. Should calculate a total pay of 600

2) Rate of 15.50, 50 hours. Should calculate 40 hours at regular rate plus 10 hours at time and a half, should calculate a total pay of 852.5

3) Rate of 11, 70.25 hours. Should calculate 10.25 hours of double time pay, plus 20 hours of time and a half plus 40 hours of regular pay for a total of 995.5

Please write this in programming C language and please explain what we are doing in each step.

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!