题解 | #编写个人所得税计算程序#
编写个人所得税计算程序
https://www.nowcoder.com/practice/7a1f759199654f9abc69a3ef2f54d451
import java.util.*; public class Main { public static void main(String[] args) { List<Employee> employees = new ArrayList<>(); //write your code here...... // 小明 小军 小红 分别为 2500 8000 100000 Employee e0 = new Employee("小明",2500); Employee e1 = new Employee("小军",8000); Employee e2 = new Employee("小红",100000); employees.add(e0); employees.add(e1); employees.add(e2); for(Employee i : employees){ double Salary = i.getSalary(); double sum = 0.0; if(Salary >= 3500){ if((Salary - 3500 ) <= 1500){ sum =(Salary - 3500 ) * 0.03 ; }else if((Salary - 3500 ) > 1500 & (Salary - 3500 ) <= 4500){ sum =(Salary - 3500 ) * 0.1 - 105; }else if((Salary - 3500 ) > 4500 & (Salary - 3500 ) <= 9000){ sum =(Salary - 3500 ) * 0.2 - 555; }else if((Salary - 3500 ) > 9000 & (Salary - 3500 ) <= 35000){ sum =(Salary - 3500 ) * 0.25 - 1005; }else if((Salary - 3500 ) > 35000 & (Salary - 3500 ) <= 55000){ sum =(Salary - 3500 ) * 0.3 - 2755; }else if((Salary - 3500 ) > 55000 & (Salary - 3500 ) <= 80000){ sum =(Salary - 3500 ) * 0.35 - 5505; }else if((Salary - 3500 ) > 80000 ){ sum =(Salary - 3500 ) * 0.45 - 13505; } } System.out.println(i.getName() +"应该缴纳的个人所得税是:" + sum); } } } 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; } }