package unit4;
public class TaxPolicy {
public static int getDeduct(double income) {
income=income-3500;
if(income<=1500) return 0;
else if(income<=4500) return 105;
else if(income<=9000) return 555;
else if(income<=35000) return 1005;
else if(income<=55000) return 2755;
else if(income<=80000) return 5505;
else return 13505;
}
public static int taxRate(double income) {
income=income-3500;
if(income<=1500) return 3;
else if(income<=4500) return 10;
else if(income<=9000) return 20;
else if(income<=35000) return 25;
else if(income<=55000) return 30;
else if(income<=80000) return 35;
else return 45;
}
}
package unit4;
public class Employee2 {
private String staff_no;
private String name;
private double salary;
private double insurancesandfund;
public Employee2(String ID,String name) {
this.staff_no=ID;
this.name=name;
}
Employee2(String ID,String name,double salary,double insurancesandfund){
this.staff_no=ID;
this.name=name;
this.salary=salary;
this.insurancesandfund=insurancesandfund;
}
public String getStaff_no() {
return staff_no;
}
public void setStaff_no(String staff_no) {
this.staff_no = staff_no;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getSalary() {
return salary;
}
public void setSalary(double salary) {
this.salary = salary;
}
public double getInsurancesandfund() {
return insurancesandfund;
}
public void setInsurancesandfund(double insurancesandfund) {
this.insurancesandfund = insurancesandfund;
}
public double getTax() {
return (salary-insurancesandfund-3500)*TaxPolicy.taxRate(salary)/100.0-TaxPolicy.getDeduct(salary);
}
public double getRealIncome() {
return salary-getTax()-insurancesandfund;
}
}
package unit4;
import java.util.Scanner;
public class PayrollTax {
public static void main(String[] args) {
Employee2 emp1=new Employee2("1001","张三",6581,812.82);
Employee2 emp2 = new Employee2("1002","李四");
System.out.println("编号:"+emp1.getStaff_no()+",姓名:"+emp1.getName()+" 的应纳税额是:"+emp1.getTax()+" 税后工资是:"+emp1.getRealIncome());
Scanner mykey = new Scanner(System.in);
System.out.println("请输入李四应发的工资:");
double income=mykey.nextDouble();
emp2.setSalary(income);
System.out.println("请输入李四应缴纳的五险一金:");
double insurance =mykey.nextDouble();
emp2.setInsurancesandfund(insurance);
System.out.println("编号:"+emp2.getStaff_no()+",姓名:"+emp2.getName()+" 的应纳税额是:"+emp2.getTax()+" 税后工资是:"+emp2.getRealIncome());
}
}