




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、精选优质文档-倾情为你奉上Java语言课程作业(第二次)题 目 第十六题 学 院 计算机学院 专 业 软件工程 班 别 14级(2 )班 学 号 姓 名 冯杰俊 2015年11月25日专心-专注-专业一、课程题目 16. 为某公司编写一个工资支付系统,用于计算某一类员工的月薪。该公司共有四类员工:领固定月薪的(SalariedEmployee),计时取酬的(HourlyEmployee,如果一月工时超过160小时,则还需对额外的工时支付加班费)、按销售额提成(CommissionEmployee)的和带底薪并按销售额提成的(BasePlusCommissionEmployee),其继承层次结构
2、如下所示。已知每类员工均有表示员工工号、姓名和出生年月的属性,和用于计算员工月薪的方法。创建一个Employee变量数组,保存Employee类层次结构中每个具体类对象的引用,对每个Employee显示其工号、姓名、出生年月和月收入,如果当月是Employee的生日所在的月份,则还另发给他100月作为红包。二、题目分析与设计 1. 题目需求: 计算每一类员工的工资 创建一个Employee变量数组,保存Employee类层次结构中每个具体类对象的引用 对每个Employee显示其工号、姓名、出生年月和月收入2. 创造一个employee抽象类,其中有employee的基本属性:工号、姓名、出生
3、年月和月收入,还有一个抽象方法,每一个类员工都是一个具体类,对抽象方法进行不同的重载,以实现不同员工不同的工资计算方法,另外因为本题没有给出当前月份、固定月薪、销售每件产品的提成、时薪、加班费等,因此本程序都以假设的方法自行设定,保存在多个接口中,在每个类中按需继承3. 继承层次结构EmployeeSalariedEmployeeCommissionEmployeeHourlyEmployeeBasePlusCommissionEmployee4. 开发环境:Eclipse三、测试分析程序输出:please enter employee type0:SalariedEmployee 1:Hou
4、rlyEmployee 2:CommissionEmployee 3:BasePlusCommissionEmployee用户输入:0(这里以固定月薪做示范,假定当前为11月,固定月薪为5000)程序输出:please enter details of this employee(name number birthyear birthmonth)for example:John9527199510用户输入:Jack5816199810name:Jacknumber:5816birthyear:1998birthmonth:10income:5000.please enter employee
5、type0:SalariedEmployee 1:HourlyEmployee 2:CommissionEmployee 3:BasePlusCommissionEmployee用户输入:0程序输出:please enter details of this employee(name number birthyear birthmonth)for example:John9527199510用户输入:Jack5816199811(其他不变,月份输入11)程序输出:name:Jacknumber:5816birthyear:1998birthmonth:11income:5100.(发了100元
6、红包)附录:源代码import java.util.Scanner; abstract class Employee public int number;public String name=new String10; public int birthYear;public int birthMonth;public static double salary;public abstract void pay(String name,int number,int birthYear,int birthMonth);interface GetMonthpublic int month=11;/假设
7、现在是11月份interface GetSalaryPerMonthpublic double salaryPerMonth=5000;/假设月薪5000元interface GetWorkTimepublic double workTime=250;/假设每个月工作时间200小时public double salaryPerHour=20;/时薪20元public double overTimePay=30;/加班费30元每小时interface GetAmountOfSaledpublic int amountOfSaled=500;/假设一个月销量500件public double sa
8、laryPerSaled=10;/假设卖一件10元interface GetBasepublic double base=2000;/假设底薪2000元class SalariedEmployee extends Employee implements GetMonth,GetSalaryPerMonthpublic void pay(String name,int number,int birthYear,int birthMonth)if(birthMonth=month) salary=salaryPerMonth+100;/当月为生日月份,则发100元发红包else salary=sa
9、laryPerMonth;System.out.printf("%sn",name+"%dn",number+"出生年月:%d %dn",birthYear,birthMonth+"月收入:%lfn",salary);class HourlyEmployee extends Employee implements GetMonth,GetWorkTimepublic void pay(String name,int number,int birthYear,int birthMonth)if(workTime>
10、;160) salary=workTime*20+(workTime-160)*30;else salary=workTime*20;if(birthMonth=month) salary+=100;/当月为生日月份,则发100元发红包System.out.printf("%sn",name+"%dn",number+"出生年月:%d %dn",birthYear,birthMonth+"月收入:%lfn",salary);class CommissionEmployee extends Employee impl
11、ements GetMonth,GetAmountOfSaledpublic void pay(String name,int number,int birthYear,int birthMonth)salary=amountOfSaled*salaryPerSaled;if(birthMonth=month) salary=+100;/当月为生日月份,则发100元发红包System.out.printf("%sn",name+"%dn",number+"出生年月:%d %dn",birthYear,birthMonth+"
12、月收入:%lfn",salary);class BasePlusCommissionEmployee extends Employee implements GetMonth,GetAmountOfSaled,GetBasepublic void pay(String name,int number,int birthYear,int birthMonth)salary=amountOfSaled*salaryPerSaled+base;if(birthMonth=month) salary=+100;/当月为生日月份,则发100元发红包System.out.printf("
13、;%sn",name+"%dn",number+"出生年月:%d %dn",birthYear,birthMonth+"月收入:%lfn",salary);public class Paysystem implements GetMonth public static void main(String args)Employee Data=new Employee4;Data0=new SalariedEmployee(); Data1=new HourlyEmployee(); Data2=new CommissionEm
14、ployee(); Data3=new BasePlusCommissionEmployee();/创建一个Employee变量数组,保存Employee类层次结构中每个具体类对象的引用, System.out.println("please enter employee typen0:SalariedEmployee 1:HourlyEmployee 2:CommissionEmployee 3:BasePlusCommissionEmployee"); Scanner s=new Scanner(System.in); int a=s.nextInt(); if(a!=
15、0&&a!=1&&a!=2&&a!=3) System.out.println("error"); System.exit(0); System.out.println("please enter details of this employee(name number birthyear birthmonth)nfor example:nJohnn9527n1995n10"); String str=s.next(); int h=s.nextInt(); int l=s.nextInt(); int m
16、=s.nextInt(); System.out.printf("name:%sn",str); System.out.printf("number:%dnbirthyear:%dnbirthmonth:%dn",h,l,m); switch(a) case(0): if (l=11) System.out.printf("income:%f",SalariedEmployee.salary=5100); else System.out.printf("income:%f",SalariedEmployee.salary=5000); ;break; case(1): if (l=11) System.out.printf("income:%f",SalariedEmployee.salary=6000); else System.out.printf("income:%f",SalariedEmployee.salary=5900); ;break; case(2): if (l=11) System.out.printf("income:%f",SalariedEmployee.salar
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农村信息化推广与应用合同
- 校园食品安全整治措施
- 手卫生课件新(黄):从认识到行动的转变
- 《石油钻探用钢丝绳及其工具》课件
- 《资金筹集》课件
- 原画游戏测试题及答案
- 智慧排水管网改造方案研究
- 心血管系统实验操作课件
- 《多元艺术》课件
- 助理广告师考试中对广告趋势的预见与把握建议试题及答案
- 河北省唐山市2023-2024学年七年级下学期期中数学试卷(含详解)
- (二模)绍兴市2025届高三高考适应性考试 政治试卷(含答案)
- 室间隔缺损的术后护理
- Unit 5 Here and Now SectionB Project 教学设计 2024-2025学年人教版(2024)七年级英语下册
- 辽宁省兽药经营质量管理规范实施细则
- 初一英语期中质量分析及整改方案
- 2025年上海市安全员-C证考试题库
- 人体发育学 第九章 婴幼儿期认知功能的发育
- XXX公路改扩建工程地质灾害危险性评估报告报告
- 学校食堂保洁服务方案(技术标)
- 激光焊接培训课件
评论
0/150
提交评论