java练习--输出员工信息并计算员工的工资

部门类:
public class Department {
String id;
String name;
public void Department(){
	System.out.println("部门信息\t部门编号:"+id+",部门名称:"+name);
	
}
}
员工类:
public class Employee {
	String id1;
	String name2;
	double Salary;
	String name3;

	public void show() {

		Scanner input = new Scanner(System.in);
		System.out.println("员工信息\t员工编号:" + id1 + ",姓名" + name2 + ",底薪" + Salary
				+ ",所在部门:" + name3);
	}

	public double countSalary(double sales) {
		double x = 0;
		if (sales < 100000) {
			x = Salary + sales * 0.01;
			System.out.println(name2 + "本月的工资为" + x + "元");

		} else if (sales > 100000 && sales < 200000) {
			x = Salary + sales * 0.02;
			System.out.println(name2 + "本月的工资为:" + x + "元");
		} else if (sales >= 200000) {
			x = Salary + sales * 0.03;
			System.out.println(name2 + "本月的工资为:" + x + "元");
		} else {
			System.out.println("输入错误!");
		}
		return x;
	}

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		Department d = new Department();
		d.id = "0001";
		d.name = "销售部";
		d.Department();
		Employee e = new Employee();
		e.id1 = "0033";
		e.name2 = "郭德纲";
		e.Salary = 2000;
		e.name3 = "销售部";
		e.show();
		System.out.println("请输入" + e.name2 + "本月的销售额:");
		double sales = input.nextDouble();
		e.countSalary(sales);
	}
}


你可能感兴趣的:(java练习--输出员工信息并计算员工的工资)