描述
个人所得税是国家对本国公民、居住在本国境内的个人的所得和境外个人来源于本国的所得征收的一种所得税。假设某地区的起征点为3500元(即月工资低于3500时不需要缴纳个人所得税),个人所得税的计算公式为:应纳税额=(工资薪金所得-扣除数)×适用税率-速算扣除数。其中,扣除数为3500元,适用税率以及速算扣除数如下表所示(注:此表并非当前国家个人所得税缴纳标准表,且为简化逻辑个人所得税的计算方式也进行了一定修改)
表-1 个人所得税缴纳标准
全月应纳税所得额 | 税率 | 速算扣除数(元) |
不超过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 |
上表中的全月应纳税所得额=工资薪金所得-扣除数。
现在请你新建三个employee对象小明,小军和小红,他们的月工资分别为2500,8000,100000。并将他们按照顺序存入集合中。遍历集合并计算他们应缴纳的个人所得税(个人所得税为double类型,保留一位小数)。
输入描述:
输出描述:
import java.util.*;
public class Account {
public static void main(String[] args) {
List<Employee> employees = new ArrayList<>();
employees.add(new Employee("小明", 2500));
employees.add(new Employee("小军", 8000));
employees.add(new Employee("小红", 100000));
for(Employee e : employees){
double tax = 0;
double income = e.getSalary() - 3500;
if(income <= 0)
tax = 0;
else if(income <= 1500)
tax = income * 0.03;
else if(income <= 4500)
tax = income * 0.1 - 105;
else if(income <= 9000)
tax = income * 0.2 - 555;
else if(income <= 35000)
tax = income * 0.25 - 1005;
else if(income <= 55000)
tax = income * 0.3 - 2755;
else if(income <= 80000)
tax = income * 0.35 - 5505;
else
tax = income * 0.45 - 13505;
System.out.println(e.getName() + "应该缴纳的个人所得税是:" + String.format("%.1f", tax));
}
}
static class Employee{
private String name;
private double salary;
public Employee (String name,double salary){
this.name = name;
this.salary = salary;
}
public String getName(){
return name;
}
public double getSalary(){
return salary;
}
}
}
总结:本题也可以用数组来进行存储和运算;示例方法是列表的方法,但总体是一样的。