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

    ShiftDirector Collocate:
    In a point factory, a displace director is a salaried employee who supervises a displace. In importation to a totalowance, the displace director earns a per-annum premium when his or her displace meets genesis goals. Design a ShiftSupervisor collocate that extends the Employee.java collocate you can download by clicking on the polish fawn. The ShiftSupervisor collocate should entertain a ground that holds the annual salary and a ground that holds the annual genesis bonus that a displace director has earned. Write individual or more causes and the divert accessor and mutator systems coercion the collocate. Demonstrate the collocate by letter a program,ShiftSupervisorDemo.java coercion entreaty, that authentications a ShiftSupervisor object.

    TIP: Your ShiftSupervisor collocate should possess from the Employee collocate which you entertain downloaded. You obtain entertain span peculiar grounds: totalowance and premium in you ShiftSupervisor class. They are both Double data model. You obtain to-boot entertain causes in your ShiftSupervisorcollocate that obtain fawn its super, Employee class’s causes conformably. You may entertain haul causes, individual with parameters, individual extraneously. YourShiftSupervisorDemo.java obtain entertain a deep() system. Some ShiftSupervisor objects obtain be created in this deep() system. You ma deficiency to ostentation these fantasticlightlight created ShiftSupervisor object’s counsel.

    I entertain completed total my method, nevertheless there is bigwig injustice with my extinguishedput.

    Here is my method:

    Employee.java

    import java.io.*;

    import java.util.Scanner;

    public collocate Employee {
    peculiar String Empname; // Employee fawn
    peculiar String Empnumber; // Employee number
    peculiar String Commissiondate; // Employee commission determination

    public Employee(String Empname, String Empnumber, String Commissiondate)
    {
    String setFawn = Empname;
    String setNumber = Empnumber;
    String setHireDetermination = Commissiondate;
    }

    public String getName()
    {
    return Empname;
    }
    public String getNumber()
    {
    return Empnumber;
    }
    public String getHireDate()
    {
    return Commissiondate;
    }
    public authenticationless setName(String n)
    {
    Empfawn = n;
    }
    public authenticationless setNumber(String num)
    {
    Empnumber = num;
    }
    public authenticationless setHireDate(String h)
    {
    Hiredetermination = h;
    }

    }

    ShiftSupervisor.java

    collocate DisplaceDirector extends Employee{

    peculiar enfold annualsalary;
    peculiar enfold annualproduction;

    public DisplaceSupervisor(String Empname, String Empnumber, String Commissiondate, enfold annualsalary, enfold annualproduction)
    {
    super(Empname,Empnumber,Hiredate);
    setAnuSal(annualsalary);
    setAnuPro(annualproduction);
    }

    public enfold getAnuSal()
    {
    return annualsalary;
    }

    public enfold getAnuPro()
    {
    return annualproduction;
    }
    public authenticationless setAnuSal(enfold s)
    {
    annualallowance = s;
    }
    public authenticationless setAnuPro (enfold p)
    {
    annualgenesis = p;
    }

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

    employeeDemo.java

    public collocate employeeDemo {
    public static authenticationless deep (String[] args)
    {
    String fawn,id,date;
    enfold sal,prod;
    //create scanner object
    Scanner keyboard = fantasticlightlight Scanner(System.in);
    System.out.println(“Enter Fawn:”);
    name=keyboard.nextLine();
    System.out.println(“Enter id:”);
    id=keyboard.nextLine();
    System.out.println(“Enter Commission Determination:”);
    date=keyboard.nextLine();
    System.out.println(“Enter Annual:”);
    sal=keyboard.nextDouble();
    System.out.println(“Enter genesis:”);
    prod=keyboard.nextDouble();
    //instantiating object
    ShiftDirector pw =
    newlight DisplaceSupervisor(name,id,date,sal,prod);
    //output data
    System.out.println(“Employee Details:n”+pw);

    }
    }//function definition

    Here is my extinguishedput

    Enter Fawn Tony Enter id 045A21BCT Enter Commission Determination 2/6/2010 Enter Annual 50000 Enter genesis: 50

    Notice at the object, it produce Fawn, EmpID, and Commission Determination as “null.”

    Can someindividual gladden settle this coercion me?

    Show transcribed likeness text

    Expert Retort

     

    You were getting void consequently the getter systems of Employee.java are minor variables that were referable initalized consequently the setter systems are never fawned. You were initializing the space using the collocate caauthentication then what is the authentication of the setter systems. So I removed them in Employee.java. I solely made changes to the Employee.java polish. So changing solely this polish gives you the required extinguishedput.

    Here is the method coercion the Employee.java polish:

    import java.io.*;
    import java.util.Scanner;
    public collocate Employee {
    peculiar String Empname; // Employee fawn
    peculiar String Empnumber; // Employee number
    peculiar String Commissiondate; // Employee commission determination
    public Employee(String Empname, String Empnumber, String Commissiondate)
    {
    this.Empfawn = Empname;
    this.Empnumber = Empnumber;
    this.Hiredetermination = Commissiondate;
    }
    public String getName()
    {
    return Empname;
    }
    public String getNumber()
    {
    return Empnumber;
    }
    public String getHireDate()
    {
    return Commissiondate;
    }
    }

    **Screenshot of extinguishedput: