计算教师工资

xiaoxiao2021-02-28  21

定义一个教师类(姓名、工龄、职称),提供计算工资的方法,工资=基础工资+工龄工资。职称工资标准为:初级2000元、中级3000元、高级5000元;工龄工资标准为100元/年。

代码如下:

package 计算工资; public class Teacher { private String name; private int lenth; private String title; public Teacher(String name, int lenth, String title) { this.name = name; this.lenth = lenth; this.title = title; } public int money() { int mn = 0; switch (title) { case "普通": mn = 3000 + lenth * 100; case "中级": mn = 5000 + lenth * 100; case "高级": mn = 8000 + lenth * 100; } return mn; } }

测试类

package 计算工资; public class Test { public static void main(String[] args) { Teacher teacher=new Teacher("张三",10,"高级"); int a=teacher.money(); System.out.println(a); } } 结果如下
转载请注明原文地址: https://www.6miu.com/read-2250004.html

最新回复(0)