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

Please help me code the following in: JAVA Please use many COMMENTS and read the

ID: 3719432 • Letter: P

Question

Please help me code the following in: JAVA

Please use many COMMENTS and read the task THOROUGHLY

PermanentHire Class Extends SalariedWorker In this section, we'll experiment with an inheritance hierarchy that has more levels. We seek to build a Permanent Hire class that will model a full-time position as a specific kind of SalariedWorker. That is to say, a PermanentHire "is a" SalariedWorker, and a SalariedWorker "is an" Employee (and an Employee "is an" Object). (1) Download the classes outlined in the first inheritance hierarchy on page one. (Employee, SalariedWorker, HourlyWorker, Accountant) (2) Look at Accountant to see an example of inheritance already completed for you (3) Create a class called PermanentHire, and this should inherit from SalariedWorker a. public class PermanentHire extends SalariedWorker 4) Once you've built PermanentHire, then you can create constructors for your class a. See the Accountant class for examples of constructors (5) Try overriding the calculateWeeklyPay) method in your subclass so it does something different than the original version. a. Consider making PermanentHire an employee that has a base salary plus a flat bonus every month, which would require a new (overridden) calculateWeeklyPay() method. (6) Using the EmployeeDriver, build a few PermanentHires with different instance data and add them to the ArrayList of Employees Be sure to see your new PermanentHires in the console output. (7) Using the EmployeeDriver, build a ColorWithAlpha and try to add it to the ArrayList of a. Employees. What error do you encounter? What does this mean?

Explanation / Answer

Below is your code: -

PermanentHire.java

//Class Declaration

public class PermanentHire extends SalariedWorker {

// flat bonus variable

public static final double FLAT_BONUS = 1000;

// private constructor

private PermanentHire() {

}

// public parametrized constructors

public PermanentHire(String name, int social) {

super(name, social, 0);

}

public PermanentHire(String name, int social, double pay) {

super(name, social, pay);

}

// method to calculate weekly pay

@Override

public double calculateWeeklyPay() {

return super.calculateWeeklyPay() + FLAT_BONUS / 4;

}

} // end class

EmployeeDriver.java

public class EmployeeDriver {

public static void main(String[] args) {

//creating PermanentHire objects

PermanentHire p1= new PermanentHire("John Rick", 12);

PermanentHire p2= new PermanentHire("Julia", 12,3000);

PermanentHire p3= new PermanentHire("Nouman", 100,10000);

PermanentHire p4= new PermanentHire("Mason Ray", 1);

//arraylist of Employee

ArrayList<Employee> employees = new ArrayList<>();

//adding PermanentHires to Arraylist

employees.add(p1);

employees.add(p2);

employees.add(p3);

employees.add(p4);

//printing the data to console.

for (Employee employee : employees) {

PermanentHire emp = (PermanentHire) employee;

System.out.println("Name: "+emp.getName()+", Social: "+emp.getSocial()+",Weekly Wage: "+emp.calculateWeeklyPay());

}

}

}

Output

Name: John Rick, Social: 12,Weekly Wage: 250.0
Name: Julia, Social: 12,Weekly Wage: 1000.0
Name: Nouman, Social: 100,Weekly Wage: 2750.0
Name: Mason Ray, Social: 1,Weekly Wage: 250.0

7. ColorWithAlpha will not be able to be added to arraylist of Employee, because ColorWithAlpha is not the child class of Employee class

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