Program Set 4 (20 Points) This assignment will give you more experience on the u
ID: 3725033 • Letter: P
Question
Program Set 4 (20 Points) This assignment will give you more experience on the use of. 1. integers (int) 2. floats (float) 3. conditionals 4. iteration The goal of this project is to make a fictitious comparison of the new federal income tax based on the new tax bill passed by the congress in December 2017 with the old federal income tax. You will ask the user to input their taxable income. Use the income brackets gen below to calculate the new and old income tax. For the sake of simplicity of the project we will only consider individuals and not married users We will also ignore any tax deductions while calculating income tax-they can significantly alter the tax, but add too much complexity for our programming project New income tax brackets (2018 and newer) Rate 10% 12% 22% 24% 32% 35% 37% Incom e range Up to $9,525 $9,526 to $38,700 $38,701 to $82,500 $82,501 to $157,500 $157,501 to$200,000 $200,001 to $500,000 over$500,000 income tax brackets (2017 and older) Rate 10% 15% Incom e range Up to $9.325 $9.326 to $37,950Explanation / Answer
class Tax:
def new_tax(self,salary):
tax=0.0;
if 0 < salary <= 9525:
tax=salary*.1;
if salary>38700:
tax=tax+(9525*.1+(38700-9525)*.12)
if 38700 > salary > 9525:
tax=tax+(9525*.1+(salary-9525)*.12);
if salary>82500:
tax=tax+(82500-38700)*.22;
if 82500> salary > 38700:
tax=tax+(salary-38700)*.22;
if salary>157500:
tax=tax+(157500-82500)*.24;
if 157000 > salary > 82500:
tax=tax+(salary-82500)*.24;
if salary>200000:
tax=tax+(200000-157500)*.32;
if 200000 > salary > 157000:
tax=tax+(salary-157500)*.32;
if salary>500000:
tax=tax+(500000-200000)*.35;
if 500000 > salary > 200000:
tax=tax+(salary-200000)*.35;
if salary>500001:
tax=tax+(salary-500000)*.37;
return tax;
def old_tax(self,salary):
tax=0.0;
if 0 < salary <= 9325:
tax=salary*.1;
if salary>37950:
tax=tax+(9325*.1+(37950-9325)*.15)
if 37950 > salary > 9325:
tax=tax+(9325*.1+(salary-9325)*.15);
if salary>91900:
tax=tax+(91900-37950)*.25;
if 91900 > salary > 37950:
tax=tax+(salary-37950)*.25;
if salary>191650:
tax=tax+(191650-91900)*.28;
if 191650 > salary > 91900:
tax=tax+(salary-91900)*.28;
if salary>416700:
tax=tax+(416700-191650)*.33;
if 416700 > salary > 191650:
tax=tax+(salary-191650)*.33;
if salary>418400:
tax=tax+(418400-416700)*.35;
if 418400 > salary > 416700:
tax=tax+(salary-416700)*.35;
if salary>418401:
tax=tax+(salary-418401)*.396;
return tax;
t=Tax();
print "Enter income"
salary=int(input())
while salary > 0:
tax=0
print "Tax in 2018 for income of $%d is %f" %(salary,t.new_tax(salary))
print "Tax in 2017 or before for income of $%d is %f" %(salary,t.old_tax(salary))
print "Enter income"
salary=int(input())
else:
print "Income is negative, don't have to calculate tax!"
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.