Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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);

}

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is Change Control and how does it operate?

Answered: 1 week ago

Question

How do Data Requirements relate to Functional Requirements?

Answered: 1 week ago