哪位老铁谁能给我解一下这个java题,,谢谢啦!
哪位老铁谁能给我解一下这个java题,,谢谢啦!工资计算系统:某公司给员工每周结算工资。有4类员工:固定工资员工(salariedemployee):无论多少工作时间,工...
哪位老铁谁能给我解一下这个java题,,谢谢啦!工资计算系统: 某公司给员工每周结算工资。有 4 类员工: 固定工资员工(salaried employee):无论多少工作时间,工资固定 小时员工(hourly employee):按工作的小时数支付工资,每周工作时间超过 40 小时外的部分按正常的 1.5 倍计算 业绩提成员工(commission employee):依据本周销售业绩以一定的比例提成作 为本周工资 基本工资附带提成员工(base-salaried commission employee):基本工资外加 本周业绩提成 综合应用所学知识,采用 Java 语言实现上面工资计算系统中的 4 类员工的工资计算
展开
若以下回答无法解决问题,邀请你更新回答
1个回答
展开全部
//看看这样行吗?以前做过这道题
public class EmployeeTest {
public static void main(String[] args) {
Employee e1 = new SalariedEmployee(200);
System.out.println("工资为:"+e1.salary());
Employee e2 = new HourlyEmployee(50, 100);
System.out.println("工资为:"+e2.salary());
Employee e3 = new CommissionEmployee(1000, 0.5);
System.out.println("工资为:"+e3.salary());
Employee e4 = new BCommissionEmployee(200, 2000,0.3);
System.out.println("工资为:"+e4.salary());
}
}
class Employee {
public double salary(){
return 0;
}
}
class SalariedEmployee extends Employee{
double s;//基本工资
public SalariedEmployee(double s){
this.s = s;
}
public double salary(){
return s;
}
}
class HourlyEmployee extends Employee{
double time;
double s;
public HourlyEmployee(double s,double time){
this.s = s;
this.time = time;
}
public double salary(){
if(time < 40)
return s*time;
return (time - 40)*1.5*s+40*s;
}
}
class CommissionEmployee extends Employee{
double results;
double rate;
public CommissionEmployee(double results,double rate){
this.results = results;
this.rate = rate;
}
public double salary(){
return results*rate;
}
}
class BCommissionEmployee extends Employee{
double s;
double results;
double rate;
public BCommissionEmployee(double s,double results,double rate){
this.s = s;
this.results = results;
this.rate = rate;
}
public double salary(){
return results*rate+s;
}
}
public class EmployeeTest {
public static void main(String[] args) {
Employee e1 = new SalariedEmployee(200);
System.out.println("工资为:"+e1.salary());
Employee e2 = new HourlyEmployee(50, 100);
System.out.println("工资为:"+e2.salary());
Employee e3 = new CommissionEmployee(1000, 0.5);
System.out.println("工资为:"+e3.salary());
Employee e4 = new BCommissionEmployee(200, 2000,0.3);
System.out.println("工资为:"+e4.salary());
}
}
class Employee {
public double salary(){
return 0;
}
}
class SalariedEmployee extends Employee{
double s;//基本工资
public SalariedEmployee(double s){
this.s = s;
}
public double salary(){
return s;
}
}
class HourlyEmployee extends Employee{
double time;
double s;
public HourlyEmployee(double s,double time){
this.s = s;
this.time = time;
}
public double salary(){
if(time < 40)
return s*time;
return (time - 40)*1.5*s+40*s;
}
}
class CommissionEmployee extends Employee{
double results;
double rate;
public CommissionEmployee(double results,double rate){
this.results = results;
this.rate = rate;
}
public double salary(){
return results*rate;
}
}
class BCommissionEmployee extends Employee{
double s;
double results;
double rate;
public BCommissionEmployee(double s,double results,double rate){
this.s = s;
this.results = results;
this.rate = rate;
}
public double salary(){
return results*rate+s;
}
}
追问
好滴谢谢
我看哈
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询