看看代码,一定会采纳的

img

img

Employee类:

public class Employee {
    private String name;
    private int salary;
    private int subsidy;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public int getSalary() {
        return salary;
    }
    public void setSalary(int salary) {
        this.salary = salary;
    }
    public int getSubsidy() {
        return subsidy;
    }
    public void setSubsidy(int subsidy) {
        this.subsidy = subsidy;
    }
    
}

IncomeTax类:


import java.util.Scanner;

public class IncomeTax {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        Employee emp = new Employee();
        System.out.print("请输入员工姓名:");
        String name = sc.next();
        emp.setName(name);
        System.out.print("请输入员工工资:");
        int gz = sc.nextInt();
        System.out.print("请输入员工加班补贴:");
        int bt = sc.nextInt();
        emp.setSalary(gz);
        emp.setSubsidy(bt);
        
        double shuijin = 0;
        int total = gz+bt-2000;
        if(total <=0)
            shuijin = 0;
        else if(total <= 500)
            shuijin = total * 0.05;
        else if (total <= 2000)
            shuijin = 500 * 0.05 + (total-500)*0.1;
        else if(total <= 5000)
            shuijin = 500 * 0.05 + 1500*0.1 + (total - 2000)*0.15;
        else if(total <=20000)
            shuijin =  500 * 0.05 + 1500*0.1 + 3000*0.15 + (total-5000)*0.2;
        else
            shuijin =  500 * 0.05 + 1500*0.1 + 3000*0.15 + 15000*0.2 + (total-20000)*0.3;
        
        System.out.println("税前收入:"+(gz+bt)+",税后收入:"+ (gz+bt-shuijin) + ",应纳所得税税额:"+shuijin);
        
    }

}

public class Employee {
    public String name;
    public int salary;
    public int subsidy;
    public Employee(){}
    public Employee(String name, int salary, int subsidy) {
        this.name = name;
        this.salary = salary;
        this.subsidy = subsidy;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getSalary() {
        return salary;
    }

    public void setSalary(int salary) {
        this.salary = salary;
    }

    public int getSubsidy() {
        return subsidy;
    }

    public void setSubsidy(int subsidy) {
        this.subsidy = subsidy;
    }
}
package com;


class Employee{
    String name;
    float salary;
    float subsidy;
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public float getSalary() {
        return salary;
    }
    public void setSalary(float salary) {
        this.salary = salary;
    }
    public float getSubsidy() {
        return subsidy;
    }
    public void setSubsidy(float subsidy) {
        this.subsidy = subsidy;
    }
    public Employee(){
        
    }
    public Employee(String name,float salary,float subsidy){
        this.name = name;
        this.salary =salary;
        this.subsidy = subsidy;
        float sum = this.salary + this.subsidy;
        float tax=0;
        if(sum<500) {
            tax = sum*0.05f;
        }else if(sum>=500 && sum<2000) {
            tax = 500 * 0.05f + (sum-500)*0.1f;
        }else if(sum>=2000 && sum<5000) {
            tax = 500 * 0.05f + 1500*0.1f + (sum - 2000)*0.15f;
        }else if(sum>=5000 && sum<20000) {
            tax = 500 * 0.05f + 1500*0.1f + 3000*0.15f + (sum-5000)*0.2f;
        }else {
            tax = 500 * 0.05f + 1500*0.1f + 3000*0.15f + 15000*0.2f + (sum-20000)*0.3f;
        }
        System.out.println(name+"的个人所得税是:"+tax);
    }
}
public class TestDemo {

    
    public static void main(String[] args) {
        Employee emp = new Employee("张三", 5000, 2000);
    }
}


原题参考如下
https://max.book118.com/html/2017/1214/144066763.shtm