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

A company pays its employees as managers (who receive a fixed weekly salary), ho

ID: 3822746 • Letter: A

Question

A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and time-and-a-half, " i.e. 1.5 times their hourly wage, for overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money per item for each of the items they produce-each pieceworker in this company works on only one type of item). Write a program to compute the weekly pay for each employee. You do not know the number of employees in advance. Each type of employee has its own pay code: Managers have pay code 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a switch to compute each employee's pay based on that employee's paycode. Within the switch, prompt the user to enter the appropriate facts your program needs to calculate each employee's pay based on that employee's paycode.

Explanation / Answer

//Find code here
import java.util.Scanner;

public class EmployeePayment {
  
   //payout variables declarations
   private static double managerPayout;
   private static double hourlyWorkerPayout;
   private static double commissionWorkerPayout;
   private static double pieceWorkerPayout;
  
   //inputs required for calculation
   private static double grossWeeklySales;
   private static double hourlySalary;
   private static double totalHoursWorked;
   private static int numOfItemsProduced;
   private static double salaryPerItems;
  
   //number of workers selected
   private static int numOfManagerWorkers = 0;
   private static int numOfHourlyWorkers = 0;
   private static int numOfCommissionWorkers = 0;
   private static int numOfPieceWorkers = 0;
   static Scanner sc = new Scanner(System.in);
   public static void main(String[] args) {
      
      
       int code;
       do{
           System.out.print("Enter paycode(1 to 4, and 0 for exit):");
           code= sc.nextInt();
           switchImpl(code);
       }while(code != 0);
         
       //Switch implementaion is here
      
      
       System.out.println("Summary of Payouts");
       System.out.println("Employee categories Number paid");
       System.out.println("-----------------------------------");
       System.out.println("Managers: "+numOfManagerWorkers);
       System.out.println("Hourly Workers: "+numOfHourlyWorkers);
       System.out.println("Commission Workers: "+numOfCommissionWorkers);
       System.out.println("Piece Workers: "+numOfPieceWorkers);
   }

  
public static void switchImpl(int code){
  
   switch(code){
  
   case 1:
       System.out.println("Manager is selected.");
       System.out.print("Enter Manager's salary:");
       managerPayout = sc.nextDouble();
       numOfManagerWorkers++;
       System.out.println("Manager's pay is $"+managerPayout);
      
   break;
  
   case 2:
       System.out.println("Horly woorker is selected.");
       System.out.print("Enter horly salary:");
       hourlySalary = sc.nextDouble();
       System.out.print("Enter total hours worked:");
       totalHoursWorked = sc.nextDouble();
       hourlyWorkerPayout = getHorlyWorkerPayout(hourlySalary,totalHoursWorked);
       numOfHourlyWorkers++;
       System.out.println("Hourly Worker's pay is $"+hourlyWorkerPayout);
   break;
  
   case 3:
       System.out.println("Commission woorker is selected.");
       System.out.print("Enter gross weekly sales: ");
       grossWeeklySales = sc.nextDouble();
       commissionWorkerPayout = getCommisionWorkerPayout(grossWeeklySales);
       numOfCommissionWorkers++;
       System.out.println("Commission worker's pay is $"+commissionWorkerPayout);
   break;
  
   case 4:
       System.out.println("Piece woorker is selected.");
       System.out.print("Enter salary per item: ");
       salaryPerItems = sc.nextDouble();
       System.out.print("Enter Number of items produced: ");
       numOfItemsProduced = sc.nextInt();
       pieceWorkerPayout = getPieceWorkerPayout(salaryPerItems,numOfItemsProduced);
       numOfPieceWorkers++;
       System.out.println("Piece Worker's pay is $"+pieceWorkerPayout);
   break;
  
   default:
       System.out.println("Oops, Invalid code selection, Please provide valid code for the employee!");

}
}
public static double getHorlyWorkerPayout(double hourlySalary,double totalHoursWorked){
  
   double extraHoyurs;
       if(totalHoursWorked <= 40){
           hourlyWorkerPayout = totalHoursWorked*4.5;
       }else if(totalHoursWorked>40){
           extraHoyurs =totalHoursWorked-40;
           hourlyWorkerPayout = hourlyWorkerPayout+ extraHoyurs*(1.5*hourlySalary);
       }
      
       return hourlyWorkerPayout;
   }

public static double getCommisionWorkerPayout(double grossWeeklySales){
  
   commissionWorkerPayout = 250+ grossWeeklySales*0.057;
   return commissionWorkerPayout;
}

public static double getPieceWorkerPayout(double salaryPerItems,int numOfItemsProduced){
  
   pieceWorkerPayout = salaryPerItems*numOfItemsProduced;
   return pieceWorkerPayout;
}

}


//Find output here........
Enter paycode(1 to 4, and 0 for exit):1
Manager is selected.
Enter Manager's salary:2000
Manager's pay is $2000.0
Enter paycode(1 to 4, and 0 for exit):2
Horly woorker is selected.
Enter horly salary:4.5
Enter total hours worked:20
Hourly Worker's pay is $90.0
Enter paycode(1 to 4, and 0 for exit):3
Commission woorker is selected.
Enter gross weekly sales: 5000
Commission worker's pay is $535.0
Enter paycode(1 to 4, and 0 for exit):4
Piece woorker is selected.
Enter salary per item: 5
Enter Number of items produced: 2
Piece Worker's pay is $10.0
Enter paycode(1 to 4, and 0 for exit):0
Oops, Invalid code selection, Please provide valid code for the employee!
Summary of Payouts
Employee categories Number paid
-----------------------------------
Managers: 1
Hourly Workers: 1
Commission Workers: 1
Piece Workers: 1

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