请编写一个个人所得税计算器,用户输入应发工资,薪金所得五险一金金额和个税免增额,输出应缴税款和实发工资结果保留小数点后两位。当输入数值小于0或等于0时,输出error
时间: 2024-05-17 18:15:19 浏览: 121
好的,我可以为您编写一个个人所得税计算器。以下是Python代码:
```python
salary = float(input("请输入应发工资:"))
insurance = float(input("请输入薪金所得五险一金金额:"))
exemption = float(input("请输入个税免增额:"))
if salary <= 0 or insurance < 0 or exemption < 0:
print("error")
else:
taxable_income = salary - insurance - exemption - 5000 # 纳税所得额
if taxable_income <= 0: # 不需要缴税
tax = 0
elif taxable_income <= 3000: # 3,000元及以下部分税率为3%
tax = taxable_income * 0.03
elif taxable_income <= 12000: # 3,000元至12,000元部分税率为10%
tax = taxable_income * 0.1 - 210
elif taxable_income <= 25000: # 12,000元至25,000元部分税率为20%
tax = taxable_income * 0.2 - 1410
elif taxable_income <= 35000: # 25,000元至35,000元部分税率为25%
tax = taxable_income * 0.25 - 2660
elif taxable_income <= 55000: # 35,000元至55,000元部分税率为30%
tax = taxable_income * 0.3 - 4410
elif taxable_income <= 80000: # 55,000元至80,000元部分税率为35%
tax = taxable_income * 0.35 - 7160
else: # 超过80,000元部分税率为45%
tax = taxable_income * 0.45 - 15160
salary_after_tax = salary - insurance - tax # 实发工资
print("应缴税款:{:.2f}元,实发工资:{:.2f}元".format(tax, salary_after_tax))
```
使用时,用户需要输入应发工资、薪金所得五险一金金额和个税免增额,程序会自动计算应缴税款和实发工资。如果输入的数值小于0或等于0,则会输出error。
希望这个计算器对您有所帮助。
阅读全文