Write a program that prompts the user for hours worked, shift, and, if the shift is 2 or 3, whether the worker elects the retirement (1 for yes, 2 for no). Display: Hours worked Shift Hourly pay rate Regular pay Overtime pay Total of regular and overtime pay Retirement deduction, if any Net pay.

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter5: Making Decisions
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Acme Parts runs a small factory and employs workers who are paid one of three hourly rates depending on their shift: first shift, $17 per hour; second shift, $18.50 per hour; third shift, $22 per hour. Each factory worker might work any number of hours per week; any hours greater than 40 are paid at one and one-half times the usual rate. In addition, second- and third-shift workers can elect to participate in the retirement plan for which 3% of the worker’s gross pay is deducted from the paychecks.

Write a program that prompts the user for hours worked, shift, and, if the shift is 2 or 3, whether the worker elects the retirement (1 for yes, 2 for no). Display:

  1. Hours worked
  2. Shift
  3. Hourly pay rate
  4. Regular pay
  5. Overtime pay
  6. Total of regular and overtime pay
  7. Retirement deduction, if any
  8. Net pay.


    What I got so far - 


    import java.util.*;
    public class AcmePay{
        public static void main(String[] args) throws Exception {
           
            final double SHIFT1_PAY = 17.00;
            final double SHIFT2_PAY = 18.50;
            final double SHIFT3_PAY = 22.00;
            final double RET_RATE = 0.03;
            final int FULLWEEK = 40;






            Scanner input = new Scanner(System.in);

            //prompt shift
            System.out.println("Please enter shift - 1, 2, or 3");
            shift = input.nextInt();

            //prompt hoursWorked
            System.out.println("Please enter hours worked");
            hoursWorked = input.nextDouble();






            switch (shift){
                case 1:
                    payRate = SHIFT1_PAY;
                    break;
                case 2:
                    payRate = SHIFT2_PAY;
                    break;
                case 3:
                    break;
                    payRate = SHIFT3_PAY;
                default:
                    payRate = 0;
                            }








          if (hoursWorked > FULLWEEK) //FULLWEEK = 40
          {
              regularPay = FULLWEEK * payRate;
              overtimePay = (hoursWorked - FULLWEEK) * OT_RATE * payRate;
          }  
          else
          {
              regularPay = hoursWorked * payRate;
              overtimePay = 0.0;
          }

          totalPay = regularPay + overtimePay;








          retDeduction = 0;
         
          if(shift == 2 || shift == 3)
          {
              System.out.println("Do you want to participate in the retirement plan?\n" +"Enter 1 for Yes and 2 for No.");

              retOption = input.nextInt();
              if (retOption == 1)
                retDeduction = totalPay * RET_RATE;
          }




            netPay = totalPay - retDeduction;
        }
    }
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning