Homework Solution: Hello, this program is done in JAVA….

    Hello, this program is done in JAVA. Description of the Assignment ShiftSupervisor Class: In a particular factory, a shift supervisor is a salaried employee who supervises a shift. In addition to a salary, the shift supervisor earns a yearly bonus when his or her shift meets production goals. Design a ShiftSupervisor class that extends the Employee.java class you can download by clicking on the file name. The ShiftSupervisor class should have a field that holds the annual salary and a field that holds the annual production bonus that a shift supervisor has earned. Write one or more constructors and the appropriate accessor and mutator methods for the class. Demonstrate the class by writing a program,ShiftSupervisorDemo.java for instance, that uses a ShiftSupervisor object. TIP: Your ShiftSupervisor class should inherit from the Employee class which you have downloaded. You will have two private fields: salary and bonus in you ShiftSupervisor class. They are both Double data type. You will also have constructors in your ShiftSupervisorclass that will call its super, Employee class's constructors accordingly. You may have tow constructors, one with parameters, one without. YourShiftSupervisorDemo.java will have a main() method. Some ShiftSupervisor objects will be created in this main() method. You ma want to display these new created ShiftSupervisor object's information. I have completed all my code, however there is something wrong with my output. Here is my code: Employee.java import java.io.*; import java.util.Scanner; public class Employee { private String Empname; // Employee name private String Empnumber; // Employee number private String Hiredate; // Employee hire date public Employee(String Empname, String Empnumber, String Hiredate) { String setName = Empname; String setNumber = Empnumber; String setHireDate = Hiredate; } public String getName() { return Empname; } public String getNumber() { return Empnumber; } public String getHireDate() { return Hiredate; } public void setName(String n) { Empname = n; } public void setNumber(String num) { Empnumber = num; } public void setHireDate(String h) { Hiredate = h; } } ShiftSupervisor.java class ShiftSupervisor extends Employee{ private double annualsalary; private double annualproduction; public ShiftSupervisor(String Empname, String Empnumber, String Hiredate, double annualsalary, double annualproduction) { super(Empname,Empnumber,Hiredate); setAnuSal(annualsalary); setAnuPro(annualproduction); } public double getAnuSal() { return annualsalary; } public double getAnuPro() { return annualproduction; } public void setAnuSal(double s) { annualsalary = s; } public void setAnuPro (double p) { annualproduction = p; } @Override public String toString() { return "Name:"+getName()+"nEmpID:"+getNumber()+"nHire Date:"+getHireDate()+"nAnnual Salary:"+annualsalary+"nProduction"+annualproduction; } } employeeDemo.java public class employeeDemo { public static void main (String[] args) { String name,id,date; double sal,prod; //create scanner object Scanner keyboard = new Scanner(System.in); System.out.println("Enter Name:"); name=keyboard.nextLine(); System.out.println("Enter id:"); id=keyboard.nextLine(); System.out.println("Enter Hire Date:"); date=keyboard.nextLine(); System.out.println("Enter Annual:"); sal=keyboard.nextDouble(); System.out.println("Enter production:"); prod=keyboard.nextDouble(); //instantiating object ShiftSupervisor pw = new ShiftSupervisor(name,id,date,sal,prod); //output data System.out.println("Employee Details:n"+pw); } }//function definition Here is my output Enter Name Tony Enter id 045A21BCT Enter Hire Date 2/6/2010 Enter Annual 50000 Enter production: 50 Notice at the end, it returns Name, EmpID, and Hire Date as "null." Can someone please fix this for me?
    Show transcribed image text

    Expert Answer

     
    You were getting null because the getter methods of Employee.ja

    Hello, this program is dindividual in JAVA.

    Description of the Assignment

    ShiftOverseer Adjust:
    In a point factory, a remove overseer is a salaried employee who supervises a remove. In union to a remuneration, the remove overseer earns a year-by-year benefit when his or her remove meets evolution goals. Design a ShiftSupervisor adjust that extends the Employee.java adjust you can download by clicking on the finish spectry. The ShiftSupervisor adjust should enjoy a room that holds the annual salary and a room that holds the annual evolution bonus that a remove overseer has earned. Write individual or past doers and the alienate accessor and mutator orders control the adjust. Demonstrate the adjust by match a program,ShiftSupervisorDemo.java control occurrence, that verifications a ShiftSupervisor object.

    TIP: Your ShiftSupervisor adjust should enjoy from the Employee adjust which you enjoy downloaded. You fullure enjoy couple referable-public rooms: remuneration and benefit in you ShiftSupervisor class. They are both Double data stamp. You fullure so enjoy doers in your ShiftSupervisoradjust that fullure fawn its super, Employee class’s doers pleasantly. You may enjoy pull doers, individual with parameters, individual extinguishedside. YourShiftSupervisorDemo.java allure enjoy a deep() order. Some ShiftSupervisor objects fullure be created in this deep() order. You ma lack to show these odd created ShiftSupervisor object’s counsel.

    I enjoy completed full my jurisprudence, however there is star wickedness with my extinguishedput.

    Here is my jurisprudence:

    Employee.java

    import java.io.*;

    import java.util.Scanner;

    public adjust Employee {
    not-public String Empname; // Employee spectry
    not-public String Empnumber; // Employee number
    not-public String Engagedate; // Employee engage conclusion

    public Employee(String Empname, String Empnumber, String Engagedate)
    {
    String setSpectry = Empname;
    String setNumber = Empnumber;
    String setHireConclusion = Engagedate;
    }

    public String getName()
    {
    return Empname;
    }
    public String getNumber()
    {
    return Empnumber;
    }
    public String getHireDate()
    {
    return Engagedate;
    }
    public invalid setName(String n)
    {
    Empspectry = n;
    }
    public invalid setNumber(String num)
    {
    Empnumber = num;
    }
    public invalid setHireDate(String h)
    {
    Hireconclusion = h;
    }

    }

    ShiftSupervisor.java

    adjust RemoveOverseer extends Employee{

    not-public inclose annualsalary;
    not-public inclose annualproduction;

    public RemoveSupervisor(String Empname, String Empnumber, String Engagedate, inclose annualsalary, inclose annualproduction)
    {
    super(Empname,Empnumber,Hiredate);
    setAnuSal(annualsalary);
    setAnuPro(annualproduction);
    }

    public inclose getAnuSal()
    {
    return annualsalary;
    }

    public inclose getAnuPro()
    {
    return annualproduction;
    }
    public invalid setAnuSal(inclose s)
    {
    annualremuneration = s;
    }
    public invalid setAnuPro (inclose p)
    {
    annualevolution = p;
    }

    @Override
    public String toString()
    {
    return “Name:”+getName()+”nEmpID:”+getNumber()+”nEngage Conclusion:”+getHireDate()+”nAnnual Remuneration:”+annualsalary+”nProduction”+annualproduction;
    }
    }

    employeeDemo.java

    public adjust employeeDemo {
    public static invalid deep (String[] args)
    {
    String spectry,id,date;
    inclose sal,prod;
    //create scanner object
    Scanner keyboard = odd Scanner(System.in);
    System.out.println(“Enter Spectry:”);
    name=keyboard.nextLine();
    System.out.println(“Enter id:”);
    id=keyboard.nextLine();
    System.out.println(“Enter Engage Conclusion:”);
    date=keyboard.nextLine();
    System.out.println(“Enter Annual:”);
    sal=keyboard.nextDouble();
    System.out.println(“Enter evolution:”);
    prod=keyboard.nextDouble();
    //instantiating object
    ShiftOverseer pw =
    odd RemoveSupervisor(name,id,date,sal,prod);
    //output data
    System.out.println(“Employee Details:n”+pw);

    }
    }//function definition

    Here is my extinguishedput

    Enter Spectry Tony Enter id 045A21BCT Enter Engage Conclusion 2/6/2010 Enter Annual 50000 Enter evolution: 50

    Notice at the purpose, it receipts Spectry, EmpID, and Engage Conclusion as “null.”

    Can someindividual gladden settle this control me?

    Show transcribed representation text

    Expert Exculpation

     

    You were getting ineffectual consequently the getter orders of Employee.java are subordinate variables that were referable initalized consequently the setter orders are never fawned. You were initializing the variation using the adjust doer then what is the verification of the setter orders. So I removed them in Employee.java. I solely made changes to the Employee.java finish. So changing solely this finish gives you the required extinguishedput.

    Here is the jurisprudence control the Employee.java finish:

    import java.io.*;
    import java.util.Scanner;
    public adjust Employee {
    not-public String Empname; // Employee spectry
    not-public String Empnumber; // Employee number
    not-public String Engagedate; // Employee engage conclusion
    public Employee(String Empname, String Empnumber, String Engagedate)
    {
    this.Empspectry = Empname;
    this.Empnumber = Empnumber;
    this.Hireconclusion = Engagedate;
    }
    public String getName()
    {
    return Empname;
    }
    public String getNumber()
    {
    return Empnumber;
    }
    public String getHireDate()
    {
    return Engagedate;
    }
    }

    **Screenshot of extinguishedput: