package demo03;
import java.util.Scanner;
public class Test03 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
float money=0,tax=0,old=0,medicare=0,outWork=0,house=0;
System.out.print("请输入应发工资:");
money=in.nextFloat();
old=(float)(money*0.08);//计算养老
medicare=(float)(money*0.02);//计算医保
outWork=(float)(money*0.002);//计算失业
house=money*0.12f;//计算住房公积金
money=money-(old+medicare+outWork+house);
/* 个人所得税计算
* 全月应纳税所得额
税率
速算扣除数(元)
* 全月应纳税额不超过1500元(5000)
3%
0
* 全月应纳税额超过1500元至4500元(8000)
10%
105
* 全月应纳税额超过4500元至9000元(12500)
20%
555
* 全月应纳税额超过9000元至35000元(38500)
25%
1005
* 全月应纳税额超过35000元至55000元(58500)
30%
2755
* 全月应纳税额超过55000元至80000元(83500)
35%
5505
* 全月应纳税额超过80000元
45%
13505
* */
// 工资5000块,计算规则:5000-3500-(5000*0.08+5000*0.02+5000*0.002+5000*0.12)== 5000-3500-(400+100+10+600)==1500-1110==390 应上税就是11.7
if(money<=3500)
tax=0;
else if(money<=5000)
tax=(money-3500)*0.03f;
else if(money<=8000)//假设工资7000块,计算时需要注意5000以下的部分按0.03计算,5001~8000部分按0.1计算,所以计算表达式如下
tax=(money-5000)*0.1f+(5000-3500)*0.03f;
else if(money<=12500)
tax=(money-8000)*0.2f+(8000-5000)*0.1f+(5000-3500)*0.03f;
else if(money<=38500)
tax=(money-12500)*0.25f+(12500-8000)*0.2f+(8000-5000)*0.1f+(5000-3500)*0.03f;
else if(money<=58500)
tax=(money-38500)*0.3f+(38500-12500)*0.25f+(12500-8000)*0.2f+(8000-5000)*0.1f+(5000-3500)*0.03f;
else if(money<=83500)
tax=(money-58500)*0.35f+(58500-38500)*0.3f+(38500-12500)*0.25f+(12500-8000)*0.2f+(8000-5000)*0.1f+(5000-3500)*0.03f;
else
tax=(money-83500)*0.45f+(83500-58500)*0.35f+(58500-38500)*0.3f+(38500-12500)*0.25f+(12500-8000)*0.2f+(8000-5000)*0.1f+(5000-3500)*0.03f;
System.out.println("养老:"+old);
System.out.println("医疗:"+medicare);
System.out.println("失业:"+outWork);
System.out.println("住房公积金:"+house);
System.out.println("您应交税:"+tax);
}
}