1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vodomira [7]
3 years ago
9

import java.util.Scanner; public class ArraySum { public static void main(String[] args) { Scanner scnr = new Scanner(System.in)

; final int NUM_ELEMENTS = 8; // Number of elements int[] userVals = new int[NUM_ELEMENTS]; // User numbers int i = 0; // Loop index int sumVal = 0; // For computing sum // Prompt user to populate array System.out.println("Enter " + NUM_ELEMENTS + " integer values..."); for (i = 0; i < NUM_ELEMENTS; ++i) { System.out.print("Value: "); userVals[i] = scnr.nextInt(); } // Determine sum sumVal = 0; for (i = 0; i < NUM_ELEMENTS; ++i) { sumVal = sumVal + userVals[i]; } System.out.println("Sum: " + sumVal); return; } }
Computers and Technology
1 answer:
VLD [36.1K]3 years ago
5 0

Answer:

There's nothing wrong with the question you posted except that it's not well presented or arranged.

When properly formatted, the program will be error free and it'll run properly.

The programming language used in the question is Java programming lamguage.

in java, the sign ";" signifies the end of each line and lines that begins with // represent comments. Using this understanding of end of lines and comments, the formatted code goes thus

import java.util.Scanner;  

public class Arraysum {  

public static void main(String[] args) {  

Scanner scnr = new Scanner(System.in);  

final int NUM_ELEMENTS = 8;

// Number of elements  

int[] userVals = new int[NUM_ELEMENTS];  

// User numbers  

int i = 0;  

// Loop index  

int sumVal = 0;  

// For computing sum  

// Prompt user to populate array  

System.out.println("Enter " + NUM_ELEMENTS + " integer values...");  

for (i = 0; i < NUM_ELEMENTS; ++i) {  

System.out.print("Value: ");  

userVals[i] = scnr.nextInt();  

}  

// Determine sum  

sumVal = 0;

for (i = 0; i < NUM_ELEMENTS; ++i)

{

sumVal = sumVal + userVals[i];

}

System.out.println("Sum: " + sumVal); return;

}

}

Also, see attachment for source file

Download java
You might be interested in
Which of the following is NOT contained on the Slide Show toolbar?
Lostsunrise [7]
B slide button is your answer
3 0
3 years ago
A touch screen can be used as both an input device and output device. explain how this is possible
Evgesh-ka [11]

Well, Touch screen is only an input device as it only takes the input resistance(or capacitance in new touch screens) value as per the touch on the screen. And this value of resistance would determine the location of the touch on the screen.

The output work is done by the LCD or LED displays, which displays some images and texts on screen.

Touch Screen is only a transparent glass which is place on that display and synchronized with the LED displays such that user is able to 'touch' or have a 'sense of touch' on the actual displays

5 0
3 years ago
What does pagination mean in Microsoft Word?
marin [14]

it means to alt f4 then that would help so it can eat the microscope then have it digested

5 0
3 years ago
Read 2 more answers
Fullform of mips plz ​
DedPeter [7]

Million instructions per second (MIPS) is an approximate measure of a computer's raw processing power.

7 0
3 years ago
What do you understand by the terms:<br> I)input<br> ii)process<br> iii)storage<br> iv)output
agasfer [191]

an output device translate information processed by the computer into a form which you can understand.

input device are used to enter information such as letters, numbers, sounds or picture into a computer.

5 0
3 years ago
Other questions:
  • Amina question and any other )
    14·1 answer
  • Hurry answerrrrrrr pleaseee
    11·2 answers
  • Fill in the blank <br>computers are closed in......​
    6·1 answer
  • Rita wants to know the size of each image in a folder. Which view will help her find this information quickly?
    13·1 answer
  • In a singing competition, there are 34 more men than women
    5·2 answers
  • True or false: It can take some time for the labs to load once you click “start lab.”
    7·1 answer
  • The keyboard shortcut to enter the current date in a field is
    11·1 answer
  • Match the parts of a CPU to their functions. Thanks in advance.
    7·1 answer
  • Which of the following is a quality of a mixed economy?
    5·1 answer
  • Write a program to find a perimeter of rectangle using SUB.. ..End SUB​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!