云题海 - 专业文章范例文档资料分享平台

当前位置:首页 > JAVA课程设计 - 员工工资管理(类的继承)

JAVA课程设计 - 员工工资管理(类的继承)

  • 62 次阅读
  • 3 次下载
  • 2025/6/25 18:23:21

JAVA课程设计——员工工资管理

importjava.util.Scanner; class Employee{ private String name; privateintbirthmonth; public String getName() { returnname; } publicvoidsetName(String name) { this.name = name; } publicintgetBirthmonth() { returnbirthmonth; } publicvoidsetBirthmonth(intbirthmonth) { this.birthmonth = birthmonth; } publicdoublegetSalary(intthismonth){ if(birthmonth==thismonth){ return 100; } else return 0; } publicvoid print(){ System.out.print(\员工信息:\\n姓名:\+name+\,出生月份:\+birthmonth+\,\); } public Employee(String name,intbirthmonth){ setName(name); setBirthmonth(birthmonth); } }

//固定工资

classSalariedEmployeeextends Employee{ privateintsalary; publicSalariedEmployee(String name, intbirthmonth,int salary) { super(name, birthmonth); this.salary=salary; } publicdoublegetSalary(intthismonth) { returnsalary+super.getSalary(thismonth); } publicintbasesalary(){returnsalary;} }

//小时工

classHourlyEmployeeextends Employee{ privateinthoursalary; privateintmonthhour; privateintsalary; publicHourlyEmployee(String name,

intbirthmonth,inthoursalary,intmonthhour) { super(name, birthmonth);

this.hoursalary=hoursalary; this.monthhour=monthhour; this.salary=hoursalary*monthhour; } publicdoublegetSalary(intthismonth) { if(this.getMonthhour()<160){returnsalary+super.getSalary(thismonth); } else {returnsalary+super.getSalary(thismonth)+0.5*this.getHoursalary()*(this.getMonthhour()-160);} } publicintgetHoursalary() { returnhoursalary; } publicintgetMonthhour() { returnmonthhour; } }

//销售人员

classSalesEmployeeextends Employee{ privateintmonthsales; privatedoublepercent; privatedoublesalary; publicSalesEmployee(String name, intbirthmonth,intmonthsales,double percent) { super(name, birthmonth); this.monthsales=monthsales; this.percent=percent; this.salary=monthsales*percent; } publicdoublegetSalary(intthismonth) { returnsalary+super.getSalary(thismonth); } publicintgetMonthsales() { returnmonthsales; } publicdoublegetPercent() { returnpercent; } }

//销售+底薪

classBasePlusSalesEmployeeextendsSalesEmployee{ privateintbasesalary; privatedoublesalary; publicBasePlusSalesEmployee(String name, intbirthmonth,intmonthsales, doublepercent,intbasesalary) { super(name, birthmonth,monthsales, percent); this.basesalary=basesalary; this.salary=monthsales*percent; } publicdoublegetSalary(intthismonth) { returnsuper.getSalary(thismonth)+basesalary;

} publicvoidsetSalary(double salary) { this.salary = salary; } publicintgetBasesalary() { returnbasesalary; } publicvoidsetBasesalary(intbasesalary) { this.basesalary = basesalary; } }

publicclass Work1 { publicstaticvoid main(String[] args) { choice(); } publicstaticvoid choice(){ inttype; int i=1; while(i<2){ Scanner sca=newScanner(System.in); System.out.println(\); System.out.println(\请输入员工类型:***************\); System.out.println(\固定工资)***********\); System.out.println(\小时工)***************\); System.out.println(\销售提成)**************\); System.out.println(\销售提成+底薪)*\); System.out.println(\退出选项*****************************\); System.out.println(\); int x=sca.nextInt(); switch(x) { case 1: SalariedEmployee a=newSalariedEmployee(\张三\,6,3000); a.print(); System.out.print(\基本工资:\+a.basesalary()+\实际工资:\); System.out.println(a.getSalary(6));break; case 2:HourlyEmployee b=newHourlyEmployee(\李四\,6,10,170); b.print(); System.out.print(\每小时工资:\+b.getHoursalary()+\,工作总时间:\+b.getMonthhour()+\,总工资:\); System.out.println(b.getSalary(6));break; case 3:SalesEmployee c=newSalesEmployee(\王五\,6,100000,0.02); c.print(); System.out.print(\销售总额:\+c.getMonthsales()+\,销售提成:\+c.getPercent()+\,总工资:\); System.out.println(c.getSalary(6));break; case 4:BasePlusSalesEmployee d=newBasePlusSalesEmployee(\王五\,6,100000,0.01,1000); d.print();

System.out.print(\销售总额:\+d.getMonthsales()+\,销售提

成:\+d.getPercent()+\,底薪:\+d.getBasesalary()+\,总工资:\); System.out.println(d.getSalary(6));break; case 5: i=5;break; default:System.out.println(\所选择的输出信息有误,请重新输入!!!\);break;

} } } }

  • 收藏
  • 违规举报
  • 版权认领
下载文档10.00 元 加入VIP免费下载
推荐下载
本文作者:...

共分享92篇相关文档

文档简介:

JAVA课程设计——员工工资管理 importjava.util.Scanner; class Employee{ private String name; privateintbirthmonth; public String getName() { returnname; } publicvoidsetName(String name) { this.name = name; } publicintgetBirthmonth() { returnbirthmonth; } publicvoidsetBirthmonth(intbirthmonth) { this.birthmonth = birthmonth; } publicdoublegetSalary(intthismonth){ if(birthm

× 游客快捷下载通道(下载后可以自由复制和排版)
单篇付费下载
限时特价:10 元/份 原价:20元
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:fanwen365 QQ:370150219
Copyright © 云题海 All Rights Reserved. 苏ICP备16052595号-3 网站地图 客服QQ:370150219 邮箱:370150219@qq.com