Java
Java
From question The problem requires you to write a Java program called AcmePay that calculates the pay for a factory worker based on their shift, hours worked, and whether they choose to participate in the retirement plan.
To start, you need to prompt the user to enter the shift, hours worked, and whether they want to participate in the retirement plan. You can use the Scanner class in Java to read the user's input.
Next, based on the shift entered by the user, you can calculate the hourly pay rate for the worker. If it is the first shift, the rate is $17 per hour. If it is the second shift, the rate is $18.50 per hour, and if it is the third shift, the rate is $22 per hour.
Once you have calculated the hourly rate, you can calculate the regular pay for the worker by multiplying the hours worked by the hourly rate. If the worker works more than 40 hours, you need to calculate the overtime pay at one and a half times the hourly rate for the extra hours worked.
If the shift is 2 or 3 and the worker chooses to participate in the retirement plan, you need to deduct 3% of the gross pay from the worker's paycheck.
Finally, you need to display the following information to the user:
- Hours worked
- Hourly pay rate
- Regular pay
- Overtime pay
- Retirement deduction, if any
- Net pay
To calculate the retirement deduction and net pay, you can subtract the retirement deduction (if any) from the total pay and round the result to two decimal places.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images