In: Computer Science
Write a program that asks the user for their filing
status (single or married) and their taxable income. Then, using
the below table, compute the tax owed and display the filing
status, taxable income, and tax owed.
If the filing status is single and the taxable income
is overbut not over the tax is of the amount
over$0$9,52510%0$9,526$38,700$952.50 +
12%$9,525$38,701$82,500$4,453.50 +22%
$38,700
$82,501unlimited$14,089.50 +24%
$82,500
If the filing status is married filing jointly and the taxable
income is overbut not overthe tax is of the amount
over$0$19,05010%$0$19,051$77,400$1,905 +
12%$19,050$77,401$165,000$8,907 +
22%$77,400$165,001unlimited$28,179 + 24%$165,000
Here are some check figures:
Single filer with $50,000 taxable income owes
$6,939.50 tax
Married filer with $25,000 taxable income owes
$2,619.00 tax
Married filer with $200,000 taxable income owes
$36,579.00 tax
Be sure to follow the Program Submission Guidelines
document from last week. Save the program and upload the .py file
here.
Program
income=None
sum=0
print("Personal Income Tax Calculator\n")
print("Valid Filing Statuses(0=Unmarried Filer, 1=Married Filing
Jointly, 2=Head of Household")
status=(int(input("Enter the filing status: ")))
while (status>3):
print("Enter valid filing status!!!")
status=(int(input("Enter the filing status:
")))
income=(float(input("Enter your taxable income: ")))
while income<0:
print("Enter valid income!!!")
income=(float(input("Enter your taxable income:
")))
# Compute tax
tax = 0
if status == 0: # Compute tax for single filers
if income <= 9525:
tax = income *
0.10
elif income <= 38700:
tax = 9525 * 0.10 +
(income - 9525) * 0.12
elif income <= 82500:
tax = 9525 * 0.10 +
(38700 - 9525) * 0.12 +(income - 38700) * 0.22
elif income <= 157500:
tax = 9525 * 0.10 +
(38700 - 9525) * 0.12 + (82500 - 38700) * 0.22 + (income - 82500) *
0.24
elif income <= 200000:
tax = 9525 * 0.10 +
(38700 - 9525) * 0.12 + \
(82500 - 38700) * 0.22 + (157500 - 82500) * 0.24 + \
(income - 200000) * 0.35
elif income <= 500000:
tax = 9525* 0.10 +
(38700 - 9525) * 0.12 + \
(82500 - 38700) * 0.22 + (157500 - 82500) * 0.24 + \
(200000 - 157500) * 0.32 + (income - 500000) * 0.35
else:
tax = 9525* 0.10 +
(38700 - 9525) * 0.12 + \
(82500 - 38700) * 0.22 + (157500 - 82500) * 0.24 + \
(200000 - 157500) * 0.32 + (500000 - 200000) * 0.35++ (income -
500000) * 0.37;
elif status == 1: # Compute tax for married file jointly
if income <= 19050:
tax = income *
0.10
elif income <= 77400:
tax = 19050 * 0.10 +
(income - 19050) * 0.12
elif income <= 165000:
tax = 19050 * 0.10 +
(77400 - 19050) * 0.12 +(income - 77400) * 0.22
elif income <= 315000:
tax = 19050 * 0.10 +
(77400 - 19050) * 0.12 + (165000 - 77400) * 0.22 + (income -
165000) * 0.24
elif income <= 400000:
tax = 19050 * 0.10 +
(77400 - 19050) * 0.12 + \
(165000 - 77400) * 0.22 + (315000 - 165000) * 0.24 + \
(income - 315000) * 0.35
elif income <= 600000:
tax = 19050 * 0.10 +
(77400 - 19050) * 0.12 + \
(165000 - 77400) * 0.22 + (315000 - 165000) * 0.24 + \
(400000 - 315000) * 0.32 + (income - 400000) * 0.35
else:
tax = 19050 * 0.10 +
(77400 - 19050) * 0.12 + \
(165000 - 77400) * 0.22 + (315000 - 165000) * 0.24 + \
(400000 - 315000) * 0.32 + (600000 - 400000) * 0.35++ (income -
600000) * 0.37;
elif status == 2: # Compute tax for head of households
if income <= 13600:
tax = income *
0.10
elif income <= 51800:
tax = 13600 * 0.10 +
(income - 13600) * 0.12
elif income <= 82500:
tax = 13600 * 0.10 +
(51800 - 13600) * 0.12 +(income - 51800) * 0.22
elif income <= 157500:
tax = 13600 * 0.10 +
(51800 - 13600) * 0.12 + (82500 - 51800) * 0.22 + (income - 82500)
* 0.24
elif income <= 200000:
tax = 13600 * 0.10 +
(51800 - 13600) * 0.12 + (82500 - 51800) * 0.22 + (157500 - 82500)
* 0.24 + \
(income - 200000) * 0.35
elif income <= 500000:
tax = 13600 * 0.10 +
(51800 - 13600) * 0.12 + (82500 - 51800) * 0.22 + (157500 - 82500)
* 0.24 + \
(200000 - 157500) * 0.32 + (income - 500000) * 0.35
else:
tax = 13600 * 0.10 +
(51800 - 13600) * 0.12 + (82500 - 51800) * 0.22 + (157500 - 82500)
* 0.24 + \
(200000 - 157500) * 0.32 + (500000 - 200000) * 0.35++ (income -
500000) * 0.37;
else:
print("Error: invalid status")
sys.exit()
# Display the result
print("Your income tax for 2018 will be : $ {:0.2f}".format(tax))
Output