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
Among the many DTP software tools available today, which is regarded as the industry standard for DTP?
nexus9112 [7]

Answer:

bland1 InDesign    Blank2 typesetting

Explanation:

4 0
4 years ago
Read 2 more answers
Suppose you have a stack ADT (i.e., an Abstract Data Type that includes operations to maintain a stack. Design a flowchart or su
Whitepunk [10]

Answer:

One approach would be to move all items from stack1 to stack2 (effectively reversing the items), then pop the top item from stack2 and then put them back.

Assume you use stack1 for enqueueing. So enqueue(x) = stack1.push(x).

Dequeueing would be:

- For all items in stack1: pop them from stack1 and push them in stack 2.

- Pop one item from stack2, which will be your dequeue result

- For all items in stack2: pop them from stack2 and push them in stack 1.

Hope it makes sense. I'm sure you can draw a diagram.

5 0
3 years ago
When on a LAN switch DHCP snooping is configured the networks that can be accessed by which clients?
kompoz [17]

Answer:

The network is accesible just for the whitelisted clients configured in the switch connected to the DHCP server

Explanation:

DHCP snooping main task is to prevent an unauthorized DHCP server from entering the our network.

Basically, in the switch we define the ports on which the traffic of the reliable DHCP server can travel. That is, we define as “trust” the ports where we have DHCP servers, DHCP relays and trunks between the switches.

8 0
4 years ago
What is the best information to include in the template name to differentiate it from other templates? Check all that apply.
KengaRu [80]

Answer:

2. version number

Explanation:

It is the version number of the template that explains how old or new it is. Also. if we want to differentiate between the two versions, then we probably have the best option as a version number to find out a template. and you just need to find the version number for it. You can have four versions in a year, and hence the year is not an option either. Also, the author's name can be the same for two software, and hence the author's name cannot be counted. The file size of the two versions can be the same as well. Hence, the file size cannot be used as well.

8 0
3 years ago
What is the function of Google Analytics? web graphics website monitor website statistics programming
Leviafan [203]

Google Analytics monitors websites so it's B. Hope this helps!

8 0
3 years ago
Read 2 more answers
Other questions:
  • A hard disk has four surfaces (that's top and bottom of two platters). Each track has 2,048 sectors and there are 131,072 (217)
    11·1 answer
  • The network administrator has configured the enterprise firewall to permit port 21 to allow FTP transfers to occur from outside
    8·1 answer
  • Why should you not perform any personal grooming task while driving?
    5·2 answers
  • A acrostic sentence for mutualism?
    10·1 answer
  • You may have noticed that the DHCP request that Phil-F¢s iMac sends is a broadcast packet, sent to Ethernet address: ff:ff:ff:ff
    5·1 answer
  • You create a new three-way mirror storage space. You format the storage space by using ReFS. Which two features can you use on t
    13·1 answer
  • Seven Features of computer aids design software
    6·1 answer
  • Which of the following contains hardware systems similar to the affected organization but does not host live data?
    13·1 answer
  • A(n) _____ is substance in which one or more atoms have the same number of protons (i.e. the same atomic number).
    6·1 answer
  • In a school 50% of the students are younger than 10, 1/20 are 10 years old and 1/10 are older than 10 but younger than 12, the r
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!