388 views
0 votes
Write a program to prompt the user for hours worked to compute a gross pay for an employee, and he is paid 100/hour. If he worked for 50 hours in a week then he will get overtime pay for the extra hours he worked i.e. he will be paid 1.5 times of M100.00 for 10 hours (50-40)

User Idz
by
5.3k points

1 Answer

4 votes

Answer:

rate = 100

hours_worked = eval(input('enter number of hours worked'))

gross_pay = hours_worked * rate

if hours_worked <= 40 :

print(gross_pay)

else:

print(gross_pay + (1.5*rate*(hours_worked -40)))

Step-by-step explanation:

Using python 3 :

The rate of pay is defined using the rate variable

The user is the prompted to enter the number of hours worked.

Gross_pay gives the mathematical evaluation of the amount paid base in rate and hours worked.

Since hours beyond 40 are paid as overtime. Then we have to add that to those who worked above 40 hours.

If hours_worked is 40 and below, then use gross pay

If gross pay is above 40 ; then the overtime fee is added to gross pay using the rate provided.

User Henna
by
4.6k points