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

write an employee class. the class will have the following fields. - Employee na

ID: 3660742 • Letter: W

Question

write an employee class. the class will have the following fields. - Employee name - Employee number in the format XXX-L, where X is a digit within the range 0-9 and the L is a letter within the range A-M. - Hire date write "set" and "get" method for each field. write no args constructor. Write constructor that has an argument for each field. Next, write a class named ProductionWorker that extends the Employee class. The ProductionWorker class should have fields to hold the following information: - Shift (an integer) - Hourly pay rate (a double) The work day is divided into two shifts: day and night. The shift field will be an integer value representing the shift that the employee works. The day shift is shift 1 and the night shift is shift 2. Write appropriate accessor and mutator methods for the class and no args constructor. write a constructor that has args for the fields. write an employee demo class that will contain a main method. the main method will create the following output -Employee John cena, ID : 123-A, hire date: 4nov 2010 -Production worker : Ibra Bou, ID: 654-R, hire date: 9 jun 1999, shift: 1, pay rate $14.50 In creating these Employees and ProductionWorkers, you must use all of the constructors and all the set and get method at least once. the main method in the EmployeeDemo class will calculate and print out the average pay rate for the Productionworkers.

Explanation / Answer

public class Employee { private String employeeName; private String employeeNumber; private String hireDate; public Employee(String n, String num, String d) { employeeName = n; employeeNumber = num; hireDate = d; } public void setName(String n) { employeeName = n; } public void setEmployeeNumber(String num) { employeeNumber = num; } public void setHireDate(String d) { hireDate = d; } public String getName() { return employeeName; } public String getEmployeeNumber() { return employeeNumber; } public String getHireDate() { return hireDate; } public String toString() { String str = "Name: " + employeeName +"Employee Number: " + employeeNumber +"Hire Date: " + hireDate; return str; } } public class ProductionWorker extends Employee { static int NIGHT_SHIFT = 2; static int DAY_SHIFT = 1; private int shift; private double payRate; private String number; private String date; public ProductionWorker (String num, String d, int sh, double rate) { number = num; date = d; shift = sh; payRate = rate; } public ProductionWorker() { // no arg } public void setShift(int s) { shift = s; } public void setPayRate(double p) { payRate = p; } public int getShift() { return shift; } public double getPayRate() { return payRate; } public String toString() { String str = "Shift: " + shift + "Hourly Rate: " + payRate; } } public class WorkerDemo { public static void main(String[] args) { String shift; Employee pw = new ProductionWorker("John Smith", "123-A", "11-15-2005", ProductionWorker.DAY_SHIFT, 16.50); System.out.println("Here's the first production worker."); System.out.println(pw); System.out.println(); pw.setName("Jon Smyth"); pw.setEmployeeNumber("123-B"); pw.setHireDate("11-15-2004"); System.out.println("After making some changes."); System.out.println(" Name: " + pw.getName()); System.out.println( " Employee Number: " + pw.getEmployeeNumber()); System.out.println(" Hire Date: " + pw.getHireDate()); System.out.println(); ProductionWorker pw2 = new ProductionWorker(); pw2.setName("Joan Jones"); pw2.setEmployeeNumber("222-L"); pw2.setHireDate("12-12-2005"); pw2.setShift(ProductionWorker.NIGHT_SHIFT); pw2.setPayRate(18.50); System.out.println(" Here's the second production worker."); System.out.println(pw2); } }