Question
In Java Please 3.4 LAB: Overtime (1) Prompt the user to enter their first and last names, the hours they worked (a whole number) and
In Java Please
3.4 LAB: Overtime
(1) Prompt the user to enter their first and last names, the hours they worked (a whole number) and their pay rate. Then calculate and display the user's full name and pay for the week. You can copy/paste your work from Lab 2 in Chapter 2, add a blank line before the final cout statement. (2 points) Use the next() method (not the nextLine() method) with the Scanner object to read the first and last name For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs.
Enter your first name: John Enter your last name: Doe Enter your hours worked: 40 Enter your pay rate: 7.25 John Doe, your pay is $290
In this program, only the payment information will be checked. Include a blank line between the input prompts and the pay result in the final cout statement.
(2) Expand the program to factor in potential overtime when calculating the pay. The user is paid time and a half for each hour worked over 40. (5 pts) The formula for overtime is:
overtime = (hours - 40) * payRate * 1.5
Replace the existing calculation with an IF/ELSE statement to determine if the user is eligible for overtime. If they are eligible, their pay is the base pay (40 * payRate) plus overtime. If they are not eligible, calculate pay using the original equation (hours * payRate).
If the user receives overtime, display the amount of overtime in addition to the pay.
Enter your first name: John Enter your last name: Doe Enter your hours worked: 50 Enter your pay rate: 7.25 John Doe, your pay is $398.75 Overtime accounts for $108.75 of that.
Enter your first name: John Enter your last name: Doe Enter your hours worked: 40 Enter your pay rate: 7.25 John Doe, your pay is $290
(3) Expand the program. If the user worked more than 70 hours, tell the user that their paycheck may be delayed 3-4 business days pending manager approval. (3)
Enter your first name: John Enter your last name: Doe Enter your hours worked: 72 Enter your pay rate: 7.25 John Doe, your pay is $638.0 Overtime accounts for $348.0 of that. You worked more than 70 hours. Your check may be delayed 3-4 business days pending manager approval.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started