104k views
1 vote
Write a program to compute an employee's weekly pay and produce a pay slip showing name, gross, pay, deductions, and net pay. The program should first prompt the user for: a. Family name b. Given name c. Hourly rate of pay d. Number of hours worked that week (Any hours over 40 are paid at double the normal hourly rate) e. A letter indicating the employee's tax category A. No tax deduction B. Tax is 10% of gross pay C. Tax is 20% of gross pay D. Tax is 29% of gross pay E. Tax is 35% of gross pay f. Either a Y or an N to indicate whether or not the employee wants $20 deducted from the weekly pay as a contribution to the United Way Charity

1 Answer

4 votes

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.

User Ikran
by
6.2k points