在main中调用出错,是不是写少了什么
package fourth;//要求:创建一个corporation类,以基本工资和工作小时为参数,计算出总工资或错误信息,在main()方法中每一个员工调用这个方法
public class corporation {
String name;
double basicWage;
int workHours;
public corporation(String name,double basicWage,int workHours)
{ this.name=name;
this.basicWage=basicWage;
this.workHours=workHours;
float wage;
//基本工资小于8元。报错
if(this.basicWage<8)
System.out.println("Error!");
else
{ //工作时间<40,,基本工资=工作小时*基本工资
if(this.workHours<=40)
{ wage=(float)(this.workHours*this.basicWage);
System.out.println(this.name+" "+wage);
}
//40<工作时间<=60,,超时工资=基本工资*1.5
else if(40<this.workHours && this.workHours<=60)
{ wage=(float)(40*this.basicWage+(this.workHours-40)*this.basicWage*1.5);
System.out.println(this.name+" "+wage);
}
//工作时间超过60小时,则出错
else
System.out.println("Error!");
}
}
public static void main(String[] args) {
corporation cor1=new corporation("员工1",7.50,35);
corporation cor2=new corporation("员工3",8.20,47);
corporation cor3=new corporation("员工3",10.00,73);
}
}