Write a complete Java program that: Prompts an employee to enter the number of hours that they have worked in a given week and stores their response in a variable named hoursWork - Only whole hours are tallied, no partial hours Prompts the employee to enter their hourly wage in dollars and stores their response in a variable named payRate Computes the employee's weekly pay check under the following rules: All hours up to and including 40, are paid at exactly the employee's hourly wage - regular pay Any / All remaining hours, are paid at one and one half times the employee's hourly wage - overtime pay Displays to the screen a brief report including: The value of all of each of the user's inputs The amount of regular pay earned The amount of overtime pay earned You can find two separate sample runs of such a program in the unnamed box below the editor window.

Respuesta :

ijeggs

Answer:

The solution is given in the explanation section

See comments for detailed explanation of each step

Explanation:

import java.util.Scanner;

public class QuestionOne{

   public static void main(String[] args) {

       Scanner in = new Scanner(System.in);

       //Prompt User for input

       System.out.println("Enter Number of Hours worked this week");

       //Receive the value for number of hours

       int hoursWork = in.nextInt();

       //Prompt user for hourly wage rate

       System.out.println("Enter your hourly rate");

       double payRate = in.nextDouble();

       //compute pay

       double regularPay =0;

       //Calculate pay When there is no overtime

       if(hoursWork <= 40){

          regularPay = hoursWork*payRate;

           System.out.println("You worked for a total of "+ hoursWork+" at "+payRate

                   +" per hour, Your total pay is "+ regularPay);

       }

       // Calculate overtime pay

       //Obtain overtime by subtracting 40 from the total hours

       else{

           int extraHours = hoursWork-40;

           double overTimePay = extraHours*(1.5*payRate);

           regularPay = 40*payRate;

           System.out.println("You worked for "+hoursWork+" your regular pay is "+ regularPay+

                   " and your overtime pay is "+overTimePay);

       }

   }

}