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: 3886653 • Letter: A

Question

A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage and 1.5 times their hourly wage for time over forty hours), commission workers (who receive 250 plus five percent of their gross weekly sales), or pieceworkers (who receives 20 dollars per part created a week). Write a program that produces an employee's gross pay for the week. Each employee type has a pay code: manager (1) hourly (2), commission (3), pieceworker (4). Your code should be able to take in the pay code and provide the appropriate prompts to the user to calculate pay. Submit your work through Blackboard.

Explanation / Answer

public class Employee {

   double weeklySal,weeklySales,hrlySal,wrkingHr,weeklyPartCreated;

   public Employee() {

      

   }

   // calculated dalary according to paycode

   public double calculateWeeklysal(int code){

       if (code == 1){

           return weeklySal;

       }

       else if (code == 2){

           if (wrkingHr <= 40) {

               return hrlySal * wrkingHr;

           }

           else {

               return (40 * hrlySal + (wrkingHr - 40) * 1.5 * hrlySal);

           }

       }

       else if (code == 3){

           return 250 + 0.05 * weeklySales;

       }

       else if(code == 4){

           return (20 * this.weeklyPartCreated);

       }

       else {

           System.out.println("invalid pay code");

           return 0;

       }

   }

   public static void main(String[] args) {

       //created employee object: Manager

      

       // fill value according to salary type like for manager- weekly sal

       Scanner sc = new Scanner( System.in);

       int i;

       System.out.println("Please enter your choice :1 for manager, 2 for hourly worker, 3 for commission worker, 4 for piece worker and other for exit");

       i = sc.nextInt();

       while (i < 5 && i > 0){

           switch(i){

           case 1 :

               Employee manager = new Employee();

               System.out.println("enter Weekly Salary of manager");

               manager.weeklySal = sc.nextDouble();

               System.out.println("enter Weekly Salary for manager");

               System.out.println(Double.toString(manager.calculateWeeklysal(1)));

               break;

           case 2:

               Employee hrWorkers = new Employee();

               System.out.println("please enter hourly Salary and working hour in week of hourly worker");

               hrWorkers.hrlySal = sc.nextDouble();

               hrWorkers.wrkingHr = sc.nextDouble();

               System.out.println("Weekly Salary for hourly worker");

               System.out.println(Double.toString(hrWorkers.calculateWeeklysal(2)));

               break;

           case 3:

               Employee cWorkers = new Employee();

               System.out.println("please enter Weekly sales of commision worker");

               cWorkers.weeklySales = sc.nextDouble();      

               System.out.println("Weekly Salary for commision worker");

               System.out.println(Double.toString(cWorkers.calculateWeeklysal(3)));

               break;

           case 4:

               Employee pWorkers = new Employee();

               System.out.println("please enter Weekly part created for piece worker");

               pWorkers.weeklyPartCreated = 20;      

               System.out.println("Weekly Salary for piece worker");

               System.out.println(Double.toString(pWorkers.calculateWeeklysal(4)));

           }

           System.out.println("Please enter your choice :1 for manager, 2 for hourly worker, 3 for commission worker, 4 for piece worker and other for exit");

           i = sc.nextInt();

          

       }

       System.out.println("Thank you ");

      

      

      

      

      

      

   }

  

}

Sample OUTPUT:

Please enter your choice :1 for manager, 2 for hourly worker, 3 for commission worker, 4 for piece worker and other for exit

1

enter Weekly Salary of manager

1200

enter Weekly Salary for manager

1200.0

Please enter your choice :1 for manager, 2 for hourly worker, 3 for commission worker, 4 for piece worker and other for exit

2

please enter hourly Salary and working hour in week of hourly worker

120

33

Weekly Salary for hourly worker

3960.0

Please enter your choice :1 for manager, 2 for hourly worker, 3 for commission worker, 4 for piece worker and other for exit

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