In: Computer Science
Create a Python program that will calculate the user’s net pay based on the tax bracket he/she is in. Your program will prompt the user for their first name, last name, their monthly gross pay, and the number of dependents.
The number of dependents will determine which tax bracket the user ends up in. The tax bracket is as followed:
After calculating the net pay, print the name of the user, the monthly gross pay, the number of dependents, the gross pay, the tax rate, and the net pay.
The formula to compute the net pay is: monthly gross pay – (monthly pay * tax rate)
SCREENSHOT:
CODE:
## input first name
f_name = input("Enter your first name: ")
## input last name
l_name = input("Enter your last name: ")
## input monthly gross pay
gross_pay = float(input("Enter your monthly gross pay: "))
## input the number of dependents
no_of_dep = int(input("Enter the number of dependents: "))
## initiaslizing tax_rate
tax_rate = 0
## determining tax_rate with no of dependents
if(no_of_dep <= 1):
tax_rate = 20
elif no_of_dep == 2 or no_of_dep == 3:
tax_rate = 15
elif no_of_dep >= 4:
tax_rate = 10
## calculating the tax on the monthly gross pay
tax = gross_pay * (tax_rate/100)
## calculating monthly net pay by deducting the tax from the gross
pay
monthly_net_pay = gross_pay - tax
## calculating the net pay
net_pay = gross_pay - (monthly_net_pay * (tax_rate/100))
## Output
print("Name: " + f_name + " " + l_name)
print("Monthly gross pay: " + str(gross_pay))
print("Monthly pay: " + str(monthly_net_pay))
print("Tax Rate: " + str(tax_rate))
print("No. of dependents: " + str(no_of_dep))
print("Net pay: " + str(net_pay))
OUTPUT: