题目要求:
设计一个员工类。该员工具有下列私有属性:编号,姓名,基本工资,奖金 提供有参构造函数:Employee(Strng ID,String name), 提供上述私有属性的读写函数.
提供计算个人所得税的方法:
工资个税的计算公式为:应纳税额=(工资薪金所得 -“五险一金”-扣除数)×适用税率-速算扣除数
最终算的雇员最终领取的工资。
package Employee;
import java.util.Scanner;
//雇员类
public class Employee {
//雇员属性
String ID;
String name;
double salary;
double bonus;
double tax;
//雇员类的构造方法
Employee(String ID,String name,double salary,double bonus){
this.ID=ID;
this.name=name;
this.salary=salary;
this.bonus=bonus;
}
//按照要求算得最终的所得工资
public void personalTax(int range){
double result=0;
if(range>0&range<1500){
tax=range*0.03;
result=salary+bonus-tax;
}
else if(range>=1500&range<4500){
tax=range*0.1-105;
result=salary+bonus-tax;
}
else if(range>=4500&range<9000){
tax=range*0.2-555;
result=salary+bonus-tax;
}
else if(range>=9000&range<35000){
tax=range*0.25-1005;
result=salary+bonus-tax;
}
else if(range>=35000&range<55000){
tax=range*0.3-2755;
result=salary+bonus-tax;
}
else if(range>=55000&range<80000){
tax=range*0.35-5505;
result=salary+bonus-tax;
}
else if(range>=80000){
tax=range*0.45-13505;
result=salary+bonus-tax;
}
System.out.println(result);
}
/**
* @author HuangRong
* @date 2013/10/18
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
System.out.println("请输入您的员工编号:");
String ID=input.next();
System.out.println("请输入您的姓名:");
String name=input.next();
System.out.println("请输入您的基本工资:");
int salary=input.nextInt();
System.out.println("请输入您的奖金:");
int bonus=input.nextInt();
System.out.println("请输入您薪金的含税级距:");
int jiju=input.nextInt();
Employee emp=new Employee(ID,name,salary,bonus);
System.out.printf("28s\n","---基本信息---");
System.out.printf("%10s%-4s","员工编号",ID);
System.out.printf("%10s%-10s","姓名",name);
System.out.printf("%4s%-4d","基本工资",salary);
System.out.printf("%4s%-4d","奖金",bonus);
System.out.println();
System.out.println("您的最终所得工资为为:");
emp.personalTax(jiju);
}
}