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

Please use JAVA to Solve this problem, and also do as per the question say to do

ID: 3918674 • Letter: P

Question

Please use JAVA to Solve this problem, and also do as per the question say to do so. there should be defaulf constructor.

thanks

ShiftSupervisor Class Design a class named Employee. this class should keep the following information in fields: Employee name Employee number in the format XXX-L, where each X is a digit within the range 0-9 and the L is a letter within the range A-M. .Hire date Write one or more constructors and appropriate accessor and mutator methods for the class A shift supervisor is a salaried employee who supervises a shift. In addition to salary, the shift supervisor earns a yearly bonus whtn his or her shift meets the production goals. Design a ShiftSupervisor class that extends the Employee class you created above. The ShiftSupervisor class should have a field that holds the annual salary and a field that holds the annual production bonus that the shift supervisor has earned. Write one or more constructors and the appropriate accessor (getters) and mutator (setters) methods for the class. Demonstrate the class by writing a program that uses a ShiftSupervisor object Make sure to process two supervisors. One is built with the full argument constructor and the second with the no-argument constructor.

Explanation / Answer

ScreenShot

---------------------------------------------

program

//Employee class
class Employee{
   //Member variables
   String empName;
   String empId;
   String empDate;
   //Default constructor
   public Employee() {
       empName="";
       empId="";
       empDate=null;
   }
   //Parameterized constructor
   public Employee(String empName,String empId,String empDate) {
       this.empName=empName;
      
       this.empDate=empDate;
       if(empId.matches("[0-9][0-9][0-9]"+"-"+"[A-M]")) {
           this.empId=empId;
       }
       else {
           System.out.println("Employee Id is wrong.");
       }
   }
   //Mutators
   public void setEmpName(String name) {
       empName=name;
   }
   public void setEmpId(String id) {
       if(empId.matches("[0-9][0-9][0-9]"+"-"+"[A-M]")) {
           this.empId=id;
       }
       else {
           System.out.println("Employee Id is wrong.");
       }
   }
   public void setEmpDate(String d) {
       empDate=d;
   }
   //Accessors
   public String getEmpName() {
       return empName;
   }
   public String getEmpId() {
       return empId;
   }
   public String getEmpDate() {
       return empDate;
   }
   //Display
   public String toString() {
       return ("Name: "+empName+" Employee Number: "+empId+" Hire Date: "+empDate+" ");
   }
}
//Supervisor class inherit from employee class
class ShiftSupervisor extends Employee{
   //Member variables
   double annualSalary;
   double bonus;
   //Default constructor
   public ShiftSupervisor() {
       annualSalary=0;
       bonus=0;
   }
   //parameterized constructor
   public ShiftSupervisor(String empName,String empId,String empDate,double annualSalary,double bonus) {
       super(empName,empId,empDate);
       this.annualSalary=annualSalary;
       this.bonus=bonus;
   }
   //Mutator
   public void setAnnualSalary(double as) {
       annualSalary=as;
   }
   public void setBonus(double b) {
       bonus=b;
   }
   //Accessor
   public double getAnnualSalary() {
       return annualSalary;
   }
   public double getBonus() {
       return bonus;
   }
   //Display
   public String toString() {
       return (super.toString()+"Annual Salary: $"+annualSalary+" Production Bonus: $"+bonus+" ");
   }
}
//Main class
public class MainEmployee {

   public static void main(String[] args) {
       //First object creation for test
       System.out.println("Here's the first shift supervisor" );
       ShiftSupervisor ss=new ShiftSupervisor("John Smith","123-A","11-15-2005",48000,6500);
       System.out.println(ss.toString());
       //Second object creation for test
       System.out.println("Here's the second shift supervisor" );
       ShiftSupervisor ssv=new ShiftSupervisor("Joan Jones","222-L","12-12-2005",55000,8000);
       System.out.println(ssv.toString());
     
   }

}

------------------------------------

Output

Here's the first shift supervisor
Name: John Smith
Employee Number: 123-A
Hire Date: 11-15-2005
Annual Salary: $48000.0
Production Bonus: $6500.0

Here's the second shift supervisor
Name: Joan Jones
Employee Number: 222-L
Hire Date: 12-12-2005
Annual Salary: $55000.0
Production Bonus: $8000.0