Question: WHAT IS WRONG WITH THE CODE BELOW CAN YOU PLEASE CHECK? import java.util.Scanner; // Needed for Scanner class //ArrayDemo1.java /** This program shows values being

WHAT IS WRONG WITH THE CODE BELOW CAN YOU PLEASE CHECK?

import java.util.Scanner; // Needed for Scanner class

//ArrayDemo1.java

/**

This program shows values being stored in an array's

elements and displayed.

*/

public class ArrayDemo1

{

public static void main(String[] args)

{

final int EMPLOYEES = 3; // Number of employees

int[] hours = new int[EMPLOYEES]; // Array of hours

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter the hours worked by " +

EMPLOYEES + " employees.");

// Get the hours worked by employee 1.

System.out.print("Employee 1: ");

hours[0] = keyboard.nextInt();

// Get the hours worked by employee 2.

System.out.print("Employee 2: ");

hours[1] = keyboard.nextInt();

// Get the hours worked by employee 3.

System.out.print("Employee 3: ");

hours[2] = keyboard.nextInt();

// Display the values entered.

System.out.println("The hours you entered are:");

System.out.println(hours[0]);

System.out.println(hours[1]);

System.out.println(hours[2]);

}

}

Step by Step Solution

3.48 Rating (161 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Your code requires some improvements use a loop to get the hours worked by each employe... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!