一、相关函数
使用Scanner扫描器函数进行输入,然后根据属于的范围使用if语句进行判断,然后进行计算,用括号表示运算的范围。
二、相关代码
import java.util.Scanner;
public class PersonalIncomeTax
{
public static void main(String[] args)
{
try (Scanner scan = new Scanner(System.in)) //创建扫描器
{
System.out.println("请输入您的工资额(去除五险一金后):");
int i = scan.nextInt();//接收用户的工资额
if(i<=3500)//工资额低于3500元时
{
System.out.println("您不需要纳税");
}
else if(0<i-3500 && i-3500<=1500)//工资与免征额之差不超过1500元时
{
System.out.println("您的纳税金额为:"+(i-3500)*0.03);
}
else if(1500<i-3500 && i-3500<=4500)//工资与免征额之差在1500元和4500元之间时
{
System.out.println("您的纳税金额为:"+((i-3500)*0.1-105));
}
else if(4500<i-3500 && i-3500<=9000)//工资与免征额之差在4500到9000元之间时
{
System.out.println("您的纳税金额为:"+((i-3500)*0.2-555));
}
else if(9000<i-3500 && i-3500<=35000)//工资与免征额之差在9000到35000之间时
{
System.out.println("您的纳税金额为;"+((i-3500)*0.25-1005));
}
else if(35000<i-3500 && i-3500<=55000)//工资与免征额之差在35000到55000之间时
{
System.out.println("您的纳税金额为:"+((i-3500)*0.3-2755));
}
else if(55000<i-3500 && i-3500<=80000)//工资与免征额之差在55000到80000之间时
{
System.out.println("您的纳税金额为:"+((i-3500)*0.35-5505));
}
else//工资与免征额之差在80000之上时
{
System.out.println("您的纳税金额为:"+((i-3500)*0.45-13505));
}
}
}
}