Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need to correct syntax and logic errors //This program calculates the user\'s gr

ID: 3671094 • Letter: N

Question

Need to correct syntax and logic errors

//This program calculates the user's gross pay

import java.util.Scanner;

//to be able to read from the keyboard

public class Pay

{

public static void main(String [] args)

{

//create a Scanner object to read from the keyboard

Scanner keyboard = new Scanner(System.in);

//identifier declarations

double = hours; //number of hours worked

double = rate; //hourly pay rate

double = pay; //gross pay

//display prompts and get input

System.out.print("How many hours did you work? ");

hours = keyboard.nextDouble();

System.out.print("How much do you get paid per hour? ");

rate = keyboard.nextDouble();

//calculations

if(hours <= 40)

pay = hours * rate;

else

pay = (hours - 40) * (1.5 * rate) + 40 * rate;

//display results

System.out.println("You earned $" + pay);

}

}

Explanation / Answer

import java.util.Scanner;

//to be able to read from the keyboard
public class Pay
{
public static void main(String [] args)
{
//create a Scanner object to read from the keyboard

Scanner keyboard = new Scanner(System.in);

double hours;
double rate;
double pay;


System.out.print("How many hours did you work? ");
hours = keyboard.nextDouble();
System.out.print("How much do you get paid per hour? ");
rate = keyboard.nextDouble();

if(hours <= 40)
pay = hours * rate;
else
pay = (hours - 40) * (1.5 * rate) + 40 * rate;

System.out.println("You earned $" + pay);
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote