我正在写一个程序,它计算工资、联邦税和销售税,然后根据工资将它们分类。之后,它应该计算每个人所有联邦税的总和,但我的程序只是添加了最新的联邦税计算。不是所有的联邦税。我只需要你帮我算出联邦税的总额。 这是我的密码:
response = "yes"
over100 = 0
btwn50to100 = 0
btwn25to50 = 0
below25 = 0
while(response=="yes") or (response=="YES"):
salary = input("Please one persons salary: ")
if(salary>=100000):
over100 = over100 + 1
FederalTax = 0.20
elif(salary>=50000) and (salary<100000):
btwn50to100 = btwn50to100 + 1
FederalTax = 0.15
elif(salary>=25000) and (salary<50000):
btwn25to50 = btwn25to50 + 1
FederalTax = 0.15
elif(salary<25000):
below25 = below25 + 1
FederalTax = 0.15
StateTax = 0.05
FederalTax = int(float(salary * FederalTax))
StateTax = int(float(salary * StateTax))
NetSalary = int(float(salary - FederalTax - StateTax))
totalfederaltax = int(float(FederalTax + FederalTax)) #This is where I messed up
print("Your federal tax is :" +str(FederalTax))
print("Your state tax is :" +str(StateTax))
print("Your net salary is: " +str(NetSalary))
response = input("Would you like to continue?(yes/no): ")
print("*****")
print("The number of pepole who earned more than 100000 is: " +str(over100))
print("The number of pepole who earned More than or equal to 50000 and less than 100000 is: " +str(btwn50to100))
print("The number of pepole who earned More than or equal to 25000 and less than 50000 is: " +str(btwn25to50))
print("The number of pepole who earned Below 25000 is: " +str(below25))
print("The total federa tax is: " +str(totalfederaltax))
这是一个有趣的节目。你知道吗
IIUC,你需要从循环外的一个变量开始,然后在循环内加上,如果你想把所有输入的总税加起来的话
相关问题 更多 >
编程相关推荐