* 工资个税的计算公式为: * 应纳税额=(工资薪金所得 -“五险一金”-扣除数)×适用税率-速算扣除数 * 起征点(5000元) * 全月应纳税所得额 税率 速算扣除数(元) * 全月应纳税额不超过1500元 3% 0 * 全月应纳税额超过1500元至4500元 10% 105 * 全月应纳税额超过4500元至9000元 20% 555 * 全月应纳税额超过9000元至35000元 25% 1005 * 全月应纳税额超过35000元至55000元 30% 2755 * 全月应纳税额超过55000元至80000元 35% 5505 * 全月应纳税额超过80000元 45% 13505 * * 1、通过键盘输入用户的月薪。 * 2、键盘输入88,则退出程序(使用break退出循环),输入66继续。
运行结果图:
代码如下:
import java.util.Scanner; public class IncomeTaxCalculator { public static void main(String[] args) { Scanner s=new Scanner(System.in); System.out.println("*****工资个税计算器*****"); while (true) { System.out.println("请输入月薪:"); double Salary = s.nextDouble();//月薪 double mSalary= Salary-5000;//应纳税所得额 (各项社保=0) double shui=0;//应纳税额 if (mSalary<=0){ System.out.println("不需要交税"); } else if (mSalary<=1500) { shui=mSalary*0.03; }else if (mSalary<=4500){ shui=mSalary*0.1-105; }else if (mSalary<=9000){ shui=mSalary*0.2-555; }else if (mSalary<=35000){ shui=mSalary*0.25-1005; }else if (mSalary<=55000){ shui=mSalary*0.3-2755; }else if (mSalary<=80000){ shui=mSalary*0.35-5505; }else { shui=mSalary*0.45-13505; } System.out.println("个税="+shui); double Income=Salary-shui; System.out.println("薪资="+Income); System.out.println("输入88,退出程序!输入66继续!"); int comm= s.nextInt(); if (comm==88){ System.out.println("程序结束!"); break; }else if (comm==66){ System.out.println("计算下一个!"); continue; } } } }