题解 | 编写个人所得税计算程序
编写个人所得税计算程序
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......
// 新建三个employee对象,将对象添加进list
Employee enp = new Employee("小明",2500);
Employee enp2 = new Employee("小军",8000);
Employee enp3 = new Employee("小红",100000);
// 将人员放入到list中
employees.add(enp);
employees.add(enp2);
employees.add(enp3);
// 遍历
for (Employee emp : employees){
// 设置起始应交税参数
double tax = 0.0;
if(emp.getSalary() > 3500){
// 应缴纳所得税计算 = 工资收入 - 起征点
double taxIn = emp.getSalary() - 3500;
if (taxIn > 80000){
tax = taxIn * 0.45 - 13505;
}else if(taxIn > 55000){
tax = taxIn * 0.35 - 5505;
}else if(taxIn > 35000){
tax = taxIn * 0.3 - 2755;
}else if(taxIn > 9000){
tax = taxIn * 0.25 - 1005;
}else if(taxIn > 4500){
tax = taxIn * 0.2 - 555;
}else if(taxIn > 1500){
tax = taxIn * 0.1 - 105;
}else{
tax = taxIn * 0.03;
}
}
System.out.println(emp.getName() + "应该缴纳的个人所得税是:" + tax);
}
}
}
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;
}
}
海康威视公司福利 1407人发布