用if-elif-else条件语句,编写工资薪金个税计算的代码逻辑
时间: 2023-06-02 08:04:01 浏览: 120
Python代码-if_elif_else格式.py
好的,这个问题我可以回答。以下是代码逻辑:
```
income = float(input("请输入您的月薪(元): "))
if income <= 5000:
tax = 0
elif income <= 8000:
tax = (income - 5000) * 0.03
elif income <= 17000:
tax = (income - 8000) * 0.1 + 210
elif income <= 30000:
tax = (income - 17000) * 0.2 + 1410
elif income <= 40000:
tax = (income - 30000) * 0.25 + 2660
elif income <= 60000:
tax = (income - 40000) * 0.3 + 4410
elif income <= 85000:
tax = (income - 60000) * 0.35 + 7160
else:
tax = (income - 85000) * 0.45 + 15160
salary = income - tax
print("您的税前工资为:%0.2f元,税后工资为:%0.2f元,应缴纳个人所得税为:%0.2f元。" % (income, salary, tax))
```
以上程序假设月薪为income元,使用if-elif-else语句对应不同的税率并计算个人所得税(tax),计算出税后工资(salary)。最后输出税前工资、税后工资和应缴纳个人所得税。
阅读全文