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
Step: 1
Your code requires some improvements use a loop to get the hours worked by each employe...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started