178k views
4 votes
Ask for a worker's hourly rate and the number of hours they've worked this week. If they work more than 40 hours they are entitled to overtime. The rate for overtime hours is 1.5 times the regular rate. Calculate their total salary including any overtime. Deduct 25% for income tax. If their regular rate is more than $50.00 per hour they pay $100 for union dues, otherwise they pay $50.00. Find the total deductions and the net pay. Display a pay slip

1 Answer

3 votes

Answer:

Written in Python:

rate = float(input("Hourly Rate: "))

hours = int(input("Work Hours: "))

if hours>40:

salary = 40 * rate + (hours - 40) * 1.5 * rate

else:

salary = rate * hours

#Remove Income Tax

afterincometax = salary - 0.25 * salary

#Determine Total Pay

if rate > 50:

totalpay = afterincometax - 100

else:

totalpay = afterincometax - 50

print("Total Pay: "+str(totalpay))

Step-by-step explanation:

This line gets hourly rate

rate = float(input("Hourly Rate: "))

This line gets work hours

hours = int(input("Work Hours: "))

The following if statement calculates salary

if hours>40:

salary = 40 * rate + (hours - 40) * 1.5 * rate -----If hours > 40, overtime is considered

else:

salary = rate * hours -----If otherwise, overtime is not considered

#Remove Income Tax

This line removes 25% income tax from the salary

afterincometax = salary - 0.25 * salary

#Determine Total Pay

The following if statement removes union dues.

if rate > 50:

totalpay = afterincometax - 100

else:

totalpay = afterincometax - 50

This line prints the totalpay

print("Total Pay: "+str(totalpay))

User Dimodi
by
4.8k points