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
Kay [80]
2 years ago
7

How to add up multiple user inputs for example: If i ask the user How many numbers do you want to add? they say 5 then i out put

Enter 5 numbers: how can i get it to add up those 5 numbers that were input.In JAVA
Computers and Technology
1 answer:
Morgarella [4.7K]2 years ago
6 0

Answer:

import java.util.Scanner;

class Main {

 public static void main(String[] args) {

   Scanner scanner = new Scanner(System.in);

   System.out.println("How many numbers do you want to add?");

   int numberOfNumbers = scanner.nextInt();

   int arrayNumbers[] = new int[numberOfNumbers];

   System.out.println("Enter " + numberOfNumbers + " numbers:\n");

   for(int i = 0; i < numberOfNumbers; i++){

     int addToArray = scanner.nextInt();

     arrayNumbers[i] = addToArray;

   }

   int sum = 0;

   for(int j = 0; j < arrayNumbers.length; j++){

     sum+=arrayNumbers[j];

   }

   System.out.println("Sum: " + sum);

 }

}

Explanation:

You might be interested in
A Lost link is an interruption or loss of the control link between the control station and the unmanned aircraft, preventing con
Vlad [161]

Answer:

There is nothing to answer from this statement.

Explanation:

Can you rephrase the statement into question?

4 0
3 years ago
Which statement best describes the difference between a spreadsheet and a database?
Dmitrij [34]

Answer:

Databases store data in tables that interact; spreadsheets store data in cells that interact.

Explanation:

3 0
2 years ago
Read 2 more answers
Is the process of modifying something to make it fit certain criteria.
alexandr402 [8]

Answer:

Design Process

8 0
2 years ago
11 of the 25 people on the bus get off at the first stop. What percent best represents the portion of the bus that got off on th
miskamm [114]

Answer:

44%

Explanation: First, you have to divided 11 by 25. Which is 0.44. And then you multiply the quotient by 100 to get your percentage.

5 0
3 years ago
Which search strategy is most similar to greedy search?
lesya692 [45]

Answer:

I think the answer would be A.

Explanation:

If I'm wrong plz let me know (I think I may be wrong)

8 0
3 years ago
Other questions:
  • Write a program totake a depth (in kilometers) inside the earth as input data;compute
    15·1 answer
  • It is important to name your files in a variety of formats. true or false
    15·2 answers
  • One common method of converting symbols into binary digits for computer processing is called ASCII​ (American Standard Code of I
    5·1 answer
  • Implement a Python function with the signature Transfer(S, T) that transfers all elements from the ArrayStack instance S onto th
    13·1 answer
  • Assume the availability of a function is_prime. Assume a variable n has been associated with positive integer. Write the stateme
    15·1 answer
  • The add_prices function returns the total price of all of the groceries in the dictionary. Fill in the blanks to complete this f
    15·1 answer
  • What is the advantages and disadvantages of hardware devices and software devices ?
    9·1 answer
  • Write the technical terms for the following statements: The repeated working capacity of computer.
    15·1 answer
  • Suppose a packet is 10K bits long, the channel transmission rate connecting a sender and receiver is 10 Mbps, and the round-trip
    10·1 answer
  • Which of the following was the first computer-animated film to win animated film to win an academy award?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!