I am getting 3 errors: public class test extends Employee (the type test is alre
ID: 3539641 • Letter: I
Question
I am getting 3 errors:
public class test extends Employee (the type test is already defined)
public class test extends Employee (the type test is already defined)
public class test (the type test is already defined)
How do I clear the errors?
// SAVE IN Employee.java
%u3000
public class test
{
private String name;
private String dept;
protected double hourly_pay;
public test(String name,String dept,double hourly_pay)
{
this.name = name;
this.dept = dept;
this.hourly_pay = hourly_pay;
}
public void set_dept(String dept)
{
this.dept = dept;
}
public void set_hourly_pay(double hourly_pay)
{
this.hourly_pay = hourly_pay;
}
public String get_employee_info()
{
return name + " is working in " + dept;
}
public double weekly_pay(int no_of_hours)
{
if(no_of_hours <40)
return hourly_pay*no_of_hours;
else
return 40.0*hourly_pay;
}
}
// SAVE IN Union_Employee.java
public class test extends Employee
{
private double dues;
public test(String name,String dept,double hourly_pay,double dues)
{
super(name,dept,hourly_pay);
this.dues = dues;
}
public void set_dues(double dues)
{
this.dues = dues;
}
public double weekly_pay(int no_of_hours)
{
double pay = 0;
if(no_of_hours<40)
pay = super.weekly_pay(no_of_hours);
else
pay = super.weekly_pay(no_of_hours) + (no_of_hours-40)*hourly_pay*1.5;
return pay-dues;
}
}
// SAVE IN Commission_Employee.java
public class test extends Employee
{
private double commission_rate;
private double sales_amount;
public test(String name,String dept,double hourly_pay,double commission_rate)
{
super(name,dept,hourly_pay);
this.commission_rate = commission_rate;
}
public void set_commission_rate(double commission_rate)
{
this.commission_rate = commission_rate;
}
public void set_sales_amount(double sales_amount)
{
this.sales_amount = sales_amount;
}
public double weekly_pay(int no_of_hours)
{
return super.weekly_pay(no_of_hours) + sales_amount*commission_rate;
}
}
// SAVE IN test.java
public class test
{
public static void main(String[] args)
{
Union_Employee UE = new Union_Employee("Kumar", "ECE Dept",8,10);
Commission_Employee CE = new Commission_Employee("Ravi", "EEE Dept",9,10);
CE.set_sales_amount(5.0);
for(int input=35; input<=45; input+=5)
{
display(UE,input);
display(CE,input);
}
}
public static void display(Employee E,int no_of_hours)
{
System.out.print(E.get_employee_info());
System.out.println(" Weekly Pay off given by " + E.weekly_pay(no_of_hours));
}
}
%u3000
%u3000
Explanation / Answer
you can't declare same class name for othere class in same project.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.