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
What is the major problem with using pneumatics for robots, and how do we correct it?
Pepsi [2]
Well m<span>ost pneumatic system issues are caused by attempts to make a cylinder and related compressed air system components do something outside of the hardware’s design parameters. In order to fix this, use a filter regulator, do not oversize the cylinder, also ensure proper plant supply pressure, make sure you are using a manual, lockable air dump valve as well.
Hope this helps!</span>
4 0
3 years ago
What is the fastest typing speed ever recorded? Please be specific!
Alex

Answer:

250 wpm for almost an hour straight. This was recorded by Barbara Blackburn in 1946.

7 0
3 years ago
A piano manufacturer employs piano technicians who inspect instruments before they are shipped to customers: a.When inspecting a
77julia77 [94]

Answer:

a.When inspecting an instrument, Technicians apply specific Inspection Tests; more than one Test can be applied for an inspection. Each piano is inspected by at least one technician, and a technician can inspect more than one instrument.

Explanation:

An Inspection test  is a formal approach used to test a system or product such as machines, package, software. This can be done by dimension inspection,  visual inspection, welding inspection, function test, factory acceptance test. Three major factors to be considered in the test plan include:

Test Coverage,

Test Methods, and

Test Responsibilities

There are specific inspection tests that should be applied when inspecting an instrument. A technician can apply more than one test type to assess the authenticity of a product. More than one technician is needed to ascertain the working mehanism of a machine to ensure it has no fault. A technician  can inspect more than one instrument depending on his diversity of specialization.

5 0
3 years ago
What is the difference between software hardware ???
defon
Software are parts of a computer system that can be seen but not touched.

Hardware are parts of a computer system that can be seen and touched
3 0
3 years ago
Read 2 more answers
To which type of domain does information on wikis belong?
Misha Larkins [42]

Answer:

Hope it helps you. ^_^

Explanation:

".info (TDLs)" domain.

3 0
3 years ago
Other questions:
  • Design the logic for a program that outputs every number from 1 through 15.
    7·2 answers
  • Which protocol would you utilize to upload files to a web server?
    14·1 answer
  • A ____________ is a set of commands which can be run by calling it by name. (Phyton)
    7·2 answers
  • What is the most likely result of a correctly installed processor, but an incorrectly installed cooler?
    6·1 answer
  • Describe how computers are used to access, retrieve, organize, process, maintain, interpret, and evaluate data and information.
    13·1 answer
  • Hey guys!
    5·2 answers
  • Draw at least 15 fabric/garment care labels on a piece of paper to be submitted the following week
    5·1 answer
  • What is a web browser​
    9·1 answer
  • A numeric test score is to be converted to a letter grade of A, B, or C according to the following rules: A score greater than 9
    15·1 answer
  • A toolbar of round buttons that appear when you move the mouse when in Slide Show view id called ____________.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!