I'm having difficulty completing my income tax program for my class, mainly the output of the Social Security Number(SSN). I believe the rest of the code is correct based on the task I was given. I have the user input the SSN with hyphens, the program splits it so it can verify the number is a valid SSN, and then I want it to output the original SSN. Please let me know if I should make any other changes.
Original Task - Compute an income tax according to the rate schedule below:
- No tax paid on the first $15,000 of income
- Tax of 5% on each dollar of income after $15,000 to $30,000
- Tax of 10% on each dollar of income after $30,000
- Each taxpayer is represented with a person's SSN, name, and income
Write a Python program to do the following:
- Prompt the user to enter the appropriate data
- Check if entered value for income is greater than 0
- If yes, calculate and display person's name, SSN, and tax
- If not, display an error message to prompt user to correct
Here is my code:
def main():
name = input("Enter full name: ")
ssn = input("Please enter social (###-##-####): ")
income = eval(input("Please enter income: "))
ssn = ssn.split("-")
tax = 0.0
if income >= 30000:
tax = ((income - 30000) * .1) + (15000 * .05)
income = income - tax
elif income >= 15000:
tax = (income - 15000) * .05
income = income - tax
elif income >= 0:
income = income
else:
print("Please enter a valid income of more than $0!")
if list(map(len,ssn)) != [3,2,4]:
print("Please enter a valid Social Security Number!")
else:
print("\nYour name:",name)
print("Your SSN: ",ssn)
print("Amount you will pay in tax: $",tax)
print("Amount you will have after tax: $",income)
main()
join
it back together. – PM 77-1