Respuesta :
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);
}
}
}