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
In the water cycle,lake water will do which of the following first
Agata [3.3K]

What are the following?

5 0
3 years ago
What does it mean to use too much jargon in a slide presentation?(computer applications)
marin [14]
B.using too much jargon means you are using words that may be unfamiliar to the audience. <span>is the answer. jargon is</span><span> difficult words that others might not understand.</span>
8 0
3 years ago
Read 2 more answers
How many bits are required to write decimal number?
Aleks [24]
There is a amount of 1,00
6 0
3 years ago
HELP PLEASE I WILL GIVE YOU 15 POINTS!
scoundrel [369]

Answer:

look up some stories if you can like about dogs or something and then write why you like animals then write about how much you need to know about dogs or cats to be a good dog/cat owner

Explanation:

I already gave you the two stories didn't I in your last questions?

4 0
3 years ago
A program in which students learn a specific skill for a particular job is called a
Ne4ueva [31]
A certification program.
7 0
3 years ago
Read 2 more answers
Other questions:
  • Will mark brainliest if correct. First come, first serve.
    15·1 answer
  • How do i add a blog to my wordpress site?
    7·1 answer
  • Which entity might hire a computer systems analyst to help catch criminals?
    14·2 answers
  • While reviewing some web page code, you notice that the html is written in all lowercase letters. you are not sure which version
    14·1 answer
  • How do you double space on microsoft word?
    5·1 answer
  • What is different between a pc mouse and a real mouse
    12·2 answers
  • A router has just received the following new IP addresses: 88.62.108.0/21, 88.62.116.0/21, 88.62.120.0/21 and 88.62.128.0/21. If
    5·1 answer
  • A security policy is a?
    11·2 answers
  • A service _ consists of overhead wires and devices that connect the power company power lines to a residence.
    8·1 answer
  • Which of the following Federal labor laws apply to
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!