68.7k views
0 votes
Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75).

User JP Duffy
by
5.1k points

1 Answer

6 votes

Answer:

Following is the program in the python language

hr = input("input hours:") #Read input by user

h1 = float(hr)

rate =input("Input Rate:") #Read RATE BY USER

r1 = float(rate) #CONVERT INTO FLOAT

if h1 <= 40: #check condition

t=h1 * r1

print (t) #DISPLAY

else :#else block

t1=(40 * r1) + (h1 -40) * r1 * 1.5

print('The pay is :')

print(t1)#DISPLAY

Output:

input hours:45

Input Rate:10.50

The pay is :

498.75

Step-by-step explanation:

Following are the description of program

  • Read the value of hour in the "hr" variable and convert into the float value in the "h1" variable .
  • Read the value of rate in the " rate" variable and convert into the float value in the "r1" variable .
  • After that check the condition of hour if block if the hour is less then or equal to 40 then it multiplied h1 *t1 otherwise else block will be executed and print the value of pay .
User Chapmanio
by
5.9k points