Answer:
# get the employee data
family_name = input("Enter family name: ")
given_name = input("Enter given name: ")
hourly_rate = int(input("Enter hourly rate of pay: "))
hours = int(input("Enter hours worked for the week: "))
tax_cat = input("Enter tax category from a through e: ")
is_charit = input("Do you want to donate $20 to charity y/n: ")
gross_pay = 0
net_pay = 0
deductions = ""
# gross_pay
if hours > 40:
gross_pay = hours * (2 * hourly_rate)
else:
gross_pay = hours * hourly_rate
# net_pay and deduction
if tax_cat == 'a':
if is_charit == 'y':
net_pay = gross_pay - 20
deduction = "$20 charity donation"
else:
net_pay = gross_pay
deduction = "0% tax"
elif tax_cat == 'b':
if is_charit == 'y':
net_pay = gross_pay - ( 0.1 * gross_pay) - 20
deduction = "$20 charity donation and 10% tax"
else:
net_pay = gross_pay - (0.1 * gross_pay)
deduction = "10% tax"
elif tax_cat == 'c':
if is_charit == 'y':
net_pay = gross_pay - ( 0.2 * gross_pay) - 20
deduction = "$20 charity donation and 20% tax"
else:
net_pay = gross_pay - (0.2 * gross_pay)
deduction = "20% tax"
elif tax_cat == 'd':
if is_charit == 'y':
net_pay = gross_pay - ( 0.29 * gross_pay) - 20
deduction = "$20 charity donation and 29% tax"
else:
net_pay = gross_pay - (0.29 * gross_pay)
deduction = "29% tax"
if tax_cat == 'e':
if is_charit == 'y':
net_pay = gross_pay - ( 0.35 * gross_pay) - 20
deduction = "$20 charity donation and 35% tax"
else:
net_pay = gross_pay - (0.35 * gross_pay)
deduction = "35% tax"
# output of the employee's weekly pay.
print(f"Employee name: {given_name} {family_name}")
print(f"Gross pay: ${gross_pay}")
print(f"Net pay: {net_pay}")
print(f"Deductions: {deduction}")
Step-by-step explanation:
The python program uses the input built-in function to prompt and get user data for the program. The gross pay returns the total pay of the employee without any deduction while net pay returns the pay with all deductions included.