import java.util.Scanner; //Needed for the Scanner class /** * This program demonstrates the use of the Scanner class */ public class Scanner1 { public static void main(String[] args) { String name; int hours; double payRate; double grossPay; //creates a scanner object to read standard input Scanner input = new Scanner(System.in); //Get the user's name System.out.print("Enter your name: "); name = input.nextLine(); //Get the number of hours worked this week //ASSUMES INTEGER INPUT System.out.print("Enter the number of hours you've worked this week: "); hours = input.nextInt(); //Get the user's hourly pay rate System.out.print("Enter your hourly pay rate: "); payRate = input.nextDouble(); //Calculate Gross Pay grossPay = hours * payRate; //Display the resulting information System.out.println("Hello, " + name); System.out.println("Your gross pay is $" + grossPay); } }