Answered! Code Listing 2-29 (Payroll .java) 1 import java util. Scanner Needed for the Scanner class 4 This program…

Code Listing 2-29 (Payroll .java) 1 import java util. Scanner Needed for the Scanner class 4 This program demonstrates the Scanner class. 7 public class Payroll 9 public static void main (String[] args) To hold a name string name 11 Hours worked int hours. 12 Hourly pay rate double pay Rate; double gross Pay, Gross pay 14 Create a Scanner object to read input. Scanner keyboard new Scanner (system. in) 18 Get the users name. 19 System. out print What is your name? 20 name keyboard next Line Get the number of hours worked this week. system. out.print (How many hours did you work this week? 24 hours keyboard. next Int 25 26 Get the users hourly pay rate. 27 system out.print (What is your hourly pay rate? pay Rate keyboard. next Double 29 30 Calculate the gross pay. 31 pay Rate hours gross Pay 32

Have to use Java program.

Program output have to came out.

Code Listing 2-29 (Payroll .java) 1 import java util. Scanner Needed for the Scanner class 4 This program demonstrates the Scanner class. 7 public class Payroll 9 public static void main (String[] args) To hold a name string name 11 Hours worked int hours. 12 Hourly pay rate double pay Rate; double gross Pay, Gross pay 14 Create a Scanner object to read input. Scanner keyboard new Scanner (system. in) 18 Get the user’s name. 19 System. out print “What is your name? 20 name keyboard next Line Get the number of hours worked this week. system. out.print (“How many hours did you work this week? 24 hours keyboard. next Int 25 26 Get the user’s hourly pay rate. 27 system out.print (“What is your hourly pay rate? pay Rate keyboard. next Double 29 30 Calculate the gross pay. 31 pay Rate hours gross Pay 32

Expert Answer

 Program :

import java.util.Scanner;
public class Payroll
{
public static void main(String []args) // main function
{
String name; // variable declaration
int hours;
double payRate;
double grossPay;
Scanner keyboard = new Scanner(System.in); // scanner class declaration
System.out.print(“What is your name? “);
name=keyboard.nextLine(); // accept the name
System.out.print(“How many hours did you work this week? “);
hours=keyboard.nextInt(); // accept number of hours
System.out.print(“What is your hourly pay rate? “);
payRate = keyboard.nextDouble(); // accept the payrate
grossPay = hours * payRate; // calculate grosspay
System.out.println(“Hello, “+name); // print the name
System.out.println(“Your gross pay is $”+grossPay); // print the grosspay
}
}

Output :

Still stressed from student homework?
Get quality assistance from academic writers!