Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help figuring out how to get rid of these erros, I\'ve posted my parent c

ID: 3623524 • Letter: I

Question

I need help figuring out how to get rid of these erros, I've posted my parent class along with the three child classes, and highlighted the error spots as well as inserted all the corresponding errors that go with them at the very bottom of this question. I know that some of them are the same error, but figured that just highlighting them all would be easiest. Any help would be greatly apprecitaed.

public abstract class Employee implements Comparable
{
private int ID;
private String firstName;
private String lastName;
private String title;
private Float totalPay;
private char type;

public Employee(int ID, String firstName, String lastName, String title, char type)
{
this.ID = ID;
this.firstName = firstName;
this.lastName = lastName;
this.title = title;
this.type = type;
}
public abstract void calculatePay();
public abstract void print();

public int getID()
{
return ID;
}

public String getFirstName()
{
return firstName;
}

public String getLastName()
{
return lastName;
}

public String getTitle()
{
return title;
}

public char getType()
{
return type;
}
public Float getTotalPay()
{
return totalPay;
}

public Float setTotalPay()
{
totalPay = 0;   //1
}
}

____________________________________________________________________________

public abstract class Commission extends Employee
{
private Float salary,commissionRate,commissionSales,threshold;

public Commission(int ID, String firstName, String lastName,String title,char type,Float totalPay, Float salary,
Float commissionRate,Float threshold)

{
super(ID,firstName,lastName,title,type,totalPay);   //2
this.salary = salary;
this.commissionRate = commissionRate;
this.threshold = threshold;
}

public Float getSalary()
{
return salary;
}

public Float getCommissionRate()
{
return commissionRate;
}

public Float getCommissionSales()
{
return commissionSales;
}

public Float getThreshold()
{
return threshold;
}

public Float setCommissionSales() //3
{
commissionSales =(float)0;
}

public void calculatePay()
{
if(commissionSales > threshold)
totalPay = (salary/24)+((commissionSales - threshold) * commissionRate); //4
else
getTotalPay(salary/24); //5
}
public void print()
{
System.out.print("Commission Based Employees: " + getFirstName() +" " + getLastName() + ""
+ getTitle() + " " + getID() +" " + commissionRate + " " + commissionSales + " "
+ salary + " " + getTotalPay());
}


}

_____________________________________________________________________________

public abstract class Hourly extends Employee
{
private Float hoursWorked,hourlyRate;
private Boolean overtimeEligible;

public Hourly(String firstName, String lastName, String title, int ID,char type, Float hourlyRate,
Boolean overtimeEligible)
{
super(firstName,lastName,title,ID); //6
this.hourlyRate = hourlyRate;
this.overtimeEligible = overtimeEligible;
}

public Float getHoursWorked()
{
return hoursWorked;
}

public Float getHourlyRate()
{
return hourlyRate;
}

public Boolean getOvertimeEligible()
{
return false;
}

public Float setHoursWorked() //7
{
hoursWorked = (float)0;
}
public void calculatePay()
{
if (hoursWorked <= 80) {
totalPay = hoursWorked * hourlyRate; //8
setTotalPay(totalpay); //9
}
else if (hoursWorked > 80)
totalPay = hoursWorked * (1.5*hourlyRate); //10

}
}
_____________________________________________________________________________

public abstract class Salaried extends Employee
{
private Float salary;

public Salaried(String firstName, String lastName,String title,int ID, Float salary,char type)//need type
{
super(firstName,lastName,title,ID,salary,type); //1
this.salary = salary;
}

public Float getSalary()
{
return salary;
}

public Float setSalary() //12
{
salary = (float)0;
}
public void calculatePay()
{
totalPay = (salary/24); //13
}

public void print()
{
System.out.print("Salaried " + getFirstName() + " " + getLastName() + " " + getTitle() + " " +
getID() + " " + salary + " " + getTotalPay());
}
}

_________________________________________________________________________________________

                                                            Error listings

1.File: C:UsersChrisDesktopJava ProgramsCs111Employee.java [line: 52]
Error: Type mismatch: cannot convert from int to java.lang.Float

2.File: C:UsersChrisDesktopJava ProgramsCs111Commission.java [line: 9]
Error: The constructor Employee(int, java.lang.String, java.lang.String, java.lang.String, char, java.lang.Float) is undefined

3.File: C:UsersChrisDesktopJava ProgramsCs111Commission.java [line: 35]
Error: This method must return a result of type java.lang.Float

4.File: C:UsersChrisDesktopJava ProgramsCs111Commission.java [line: 43]
Error: The field Employee.totalPay is not visible

5.File: C:UsersChrisDesktopJava ProgramsCs111Commission.java [line: 45]
Error: The method totalPay(float) is undefined for the type Commission

6.File: C:UsersChrisDesktopJava ProgramsCs111Hourly.java [line: 9]
Error: The constructor Employee(java.lang.String, java.lang.String, java.lang.String, int) is undefined

7.File: C:UsersChrisDesktopJava ProgramsCs111Hourly.java [line: 29]
Error: This method must return a result of type java.lang.Float

8.File: C:UsersChrisDesktopJava ProgramsCs111Hourly.java [line: 36]
Error: The field Employee.totalPay is not visible

9.File: C:UsersChrisDesktopJava ProgramsCs111Hourly.java [line: 37]
Error: totalpay cannot be resolved to a variable

10.File: C:UsersChrisDesktopJava ProgramsCs111Hourly.java [line: 40]
Error: The field Employee.totalPay is not visible

11.File: C:UsersChrisDesktopJava ProgramsCs111Salaried.java [line: 7]
Error: The constructor Employee(java.lang.String, java.lang.String, java.lang.String, int, java.lang.Float, char) is undefined

12.File: C:UsersChrisDesktopJava ProgramsCs111Salaried.java [line: 16]
Error: This method must return a result of type java.lang.Float

13.File: C:UsersChrisDesktopJava ProgramsCs111Salaried.java [line: 22]
Error: The field Employee.totalPay is not visible

Explanation / Answer

error 1: type mismatch.
--> change: totalPay = 0; TO: totalPay = 0.0; or simply cast to float totalPay = (float)0;

error 2: add the float parameter to your Employee class
public Employee(int ID, String firstName, String lastName, String title, char type, float myFloat)

error 3: you are missing your return statement:

return myFloat;

error 4: you have it set to a private variable. change it to public

error 5: your getTotalPay() method does not take a parameter! if you want it to take a parameter of float change it to: public float getTotalPay(float pay){ return totalPay;

error 6: again you do not have an int declared in your Employee class

error 7: again you forgot your return statement. public float setHoursWorked() { hoursWorked = (float)0; return hoursWorked;

error 8: this error is the same as error 4.

error 9: add some print statements before and after you do your arithmatic. that way you can see if totalPay is populated or not and exactly what it has in it :)

error 10: again repeat of 4 and 8

error 11:

error 12: forgot your return statement :) return salary;

error 13: repeat of 4 and 8.

I dont have your main method so I cant really test it out. if you provide it I can help further. :) I didnt actually put your code into my IDE to run it :)




Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote