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

In Java You have been hired by the Sandwich Queen Company to help organize their

ID: 3574357 • Letter: I

Question

In Java

You have been hired by the Sandwich Queen Company to help organize their employees. Create an Employee superclass which contains: A field for name A field for payrate A constructor that assigns the fields Create a class called SandwichArtisan which extends Employee and contains: A field for the number of sandwiches made per hour A field for customers served per hour Appropriate constructor and accessors Create a class called QueenManager which extends Employee and contains: A field for the number of employees managed A field for the paybonus the manager receives A void method that calculates the paybonus as: paybonus = total customers served per hour * 2 The method must take an array of SandwichArtisans as an argument to calculate the total customers served by all the artisans. Store the result in your class field. Appropriate constructor and accessors Write a main class which creates 1 QueenManager and 3 SandwichArtisans, making up values for their fields (no need to ask the user). Add the 3 SandwichArtisans to an array and use it to calculate the paybonus of the Manager. Output the name and paybonus earned by the manager. Search your array for the employee with the most customers served and output the name of that employee as the employee of the month.

Explanation / Answer

Please find the required solution:

//Super class employee
public class Employee {

   // Required fields
   String name;
   double payRate;


   // constructor
   public Employee(String name, double payRate) {
       super();
       this.name = name;
       this.payRate = payRate;
   }
}

public class SandwichArtisan extends Employee {

   int numSandiwches;
   // number customers served for hour
   int serveRate;


   public SandwichArtisan(String name, double payRate, int numSandiwches,
           int serveRate) {
       super(name, payRate);
       this.numSandiwches = numSandiwches;
       this.serveRate = serveRate;
   }


   public int getNumSandiwches() {
       return numSandiwches;
   }


   public int getServeRate() {
       return serveRate;
   }

}

public class QueenManager extends Employee {

   int numEmp;
   double payBonus;


   public QueenManager(String name, double payRate) {
       super(name, payRate);
   }


   void calculatePayBonus(SandwichArtisan[] input) {
       double result = 0;
       for (SandwichArtisan artisan : input) {
           result = result + artisan.payRate;
       }
       payBonus = result;
       numEmp = input.length;
   }


   public int getNumEmp() {
       return numEmp;
   }


   public double getPayBonus() {
       return payBonus;
   }

}

public class MainClass {

   public static void main(String[] args) {

       // Create instance of Queen manager
       QueenManager manager = new QueenManager("Raghu", 10);

       // Create array of SandwichArtisan
       SandwichArtisan[] input = new SandwichArtisan[3];
       input[0] = new SandwichArtisan("RT1", 5, 5, 4);
       input[1] = new SandwichArtisan("RT2", 12, 2, 8);
       input[2] = new SandwichArtisan("RT3", 3, 3, 3);

       // Calculate bonus
       manager.calculatePayBonus(input);
       System.out.println("Manager name:" + manager.name);
       System.out.println("Paybonus:" + manager.getPayBonus());

       int maxIndex = 0, max = 0;
       // find customers with max served
       for (int i = 0; i < input.length; i++) {
           if (input[i].serveRate > max) {
               max = input[i].serveRate;
               maxIndex = i;
           }

       }
       System.out.println("Customer with max serve rate:"
               + input[maxIndex].name);
   }
}

Sample output:

Manager name:Raghu
Paybonus:20.0
Customer with max serve rate:RT2

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