Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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... 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

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Programming questions

Question

What is a domain?

Answered: 1 week ago

Question

Describe the purpose of the PROJECT command in relational algebra.

Answered: 1 week ago