设计并实现一个员工(Employee)类,其成员变量有:姓名,性别,工龄,基础工资,岗位津贴,效益工资。成员方法有:

(1)计算应付工资

(2)计算个人所得税(3500以下免税,超出3500以上部分按3%缴纳)

(3)实发工资

创建Employee类

package 笔记;

//创建Employee类
public class Employee {

	private String name;
               //姓名
	
	private String sex ;
               //性别
	
	private int workage;
                //工龄
	
	private double salary;              //基础工资
	
	private double subsidy;            //岗位津贴
	
	private double benefit;           //效益工资

	public String getName() {
		return name;
	}

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

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public int getWorkage() {
		return workage;
	}

	public void setWorkage(int workage) {
		this.workage = workage;
	}

	public double getSalary() {
		return salary;
	}

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

	public double getSubsidy() {
		return subsidy;
	}

	public void setSubsidy(double subsidy) {
		this.subsidy = subsidy;
	}

	public double getBenefit() {
		return benefit;
	}

	public void setBenefit(double benefit) {
		this.benefit = benefit;
	}

	/**
	 * @param name
	 * @param sex
	 * @param workage
	 * @param salary
	 * @param subsidy
	 * @param benefit
	 */
	public Employee(String name, String sex, int workage, double salary, double subsidy, double benefit) {
		super();
		this.name = name;
		this.sex = sex;
		this.workage = workage;
		this.salary = salary;
		this.subsidy = subsidy;
		this.benefit = benefit;
	}
	//应付工资
	
	public double Yfmoney() {
		
		return this.salary+this.subsidy+this.benefit;
	}
	
	//缴税
	
	public double Tax() {
		
		if(this.Yfmoney()<=3500) {
			return 0.0f;
		}
		else {
			return (this.Yfmoney()-3500)*0.03f;
        //超过部分计算
			
		}
		
	}
	
	
	//实发工资
	public double Sfmoney() {
		
		return this.Yfmoney()-this.Tax();
           //应发工资-税
	}

	@Override
	public String toString() {
		return "姓名"+name+"\n性别"+sex+"\n工龄"+workage+"\n应付工资"+Yfmoney()+"\n实发工资"+Sfmoney();
	}

	


	
}

main()方法中生成一个员工对象显示出该员工信息

package 笔记;

public class main1 {

	public static void main(String []args) {
		
		Employee total = new Employee("小明", "男", 2, 15000,5000, 5000);
		System.out.println(total);
	}
}

结果:

姓名小明
性别男
工龄2
应付工资25000.0
实发工资24355.000


过尽千帆皆不是,斜晖脉脉水悠悠