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
Gnom [1K]
3 years ago
6

Write a program that asks the user to enter a series of numbers separated by commas. Here is an example of valid input: 7,9,10,2

,18,6 The program should calculate and display the sum of all the numbers.

Computers and Technology
1 answer:
alex41 [277]3 years ago
8 0

Answer:

Here is the JAVA program. Let me know if you need the program in some other programming language.

import java.util.Scanner; // used for taking input from user

public class Main{ //Main class

public static void main(String[] args) {//start of main() function body

  Scanner scan = new Scanner(System.in); // creates a Scanner type object

   String input; // stores input series

    int sum = 0; //stores the sum of the series

    System.out.println("Enter a series of numbers separated by commas: "); //prompts user to enter a series of numbers separated by comma

     input = scan.nextLine(); //reads entire input series

     String[] numbers = input.split("[, ]"); //breaks the input series based on delimiter i.e. comma and stores the split sub strings (numbers) into the numbers array

   for (int i = 0; i < numbers.length; i++) { //loops through each element of numbers array until the length of the numbers reaches

          sum += Integer.parseInt(numbers[i]); } // parses the each String element of numbers array as a signed decimal integer object and takes the sum of all the integer objects

     System.out.println("Sum of all the numbers: " + sum);  } } //displays the sum of all the numbers

Explanation:

The program prompts the user to enter a series separated by commas.

Then split() method is used to split or break the series of numbers which are in String form, into sub strings based on comma (,) . This means the series is split into separate numbers. These are stored in numbers[] array.

Next the for loop iterate through each sub string i.e. each number of the series, converts each String type decimal number to integer using Integer.parseInt and computes the sum of all these integers. The last print statement displays the sum of all numbers in series.  

If the input is 7,9,10,2,18,6

Then the output is: 7+9+10+2+18+6

sum = 52

The program and its output is attached.

You might be interested in
Write a memo to the vice president, outlining the steps an employee might have taken to create an e-mail message and make it app
Natali [406]

Answer:

Following are the memo to the vice president:

Explanation:

In this question, the president claims, that he got a threatening e-mail from the Maui worker. HR acknowledged that all of the workers should always be dismissed, in its protection, that worker claims that he did not send the message but he does not recognize why the message implies him return address. Here is a note for the vice president, who explains how an employee could have produced an email and made it look to be from another worker's account. That stuff we want will be progressively explained as follows:

a) The manipulating and e-mail used only by spammers and attackers were called this technique. In the SMTP server, it sends messages, that you can set up to send your spammer to the email addresses. Instead of a mail confirmation, I d the forger requires the receiver to see the next employee I d email. that recipient doesn't understand who sent the message.

b) The e-mail Systems information allowing for accessible transfer is used by the intruder or forger. It  must use an attacker order to verify communication with the SMTP server command:  

telnet smpt.server.name 25    

Its name of the SMTP server is smpt.domain.name, and the port is 25.

c) when the last stage is successful as well as a link created, this order to imitate an email account only with command can be entered:

MAIL from: Email-id

It creates a problem for the worker that sends the e-mail with the same id

d) Hacker sets the email of the receiver to:  

RCPT to: boss email-id  

It sets the beneficiary as the e-mail above.  

e) By entering an order, you can create the email data:  

DATA It may also adjust the date by using command and Any date we would like to use.  

Date: (date you would like)  

We should settle on the following:  

Subject: (your topic)

f) We press Insert after the topic is written. In this body can then be e-mail forms. It produces the text.  

g) its email forged is forwarded.

3 0
4 years ago
What is the advantage of defining a target user?
spayn [35]
3) helps the designer develop a website tailored to the desired audience
4 0
3 years ago
_______ are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often
Damm [24]

Answer: sales promotion

Explanation:

Sales promotion are special incentives or excitement-building programs that encourage consumers to purchase a particular product, often used in conjunction with advertising or personal selling programs.

5 0
4 years ago
What is an assembler?
Flauer [41]

an assembler is a program that converts code written in a high-level language to assembly language that the computer processor can execute.

4 0
3 years ago
PLEASE HELP PROGRAMMING WILL GIVE BRAINLIEST
DaniilM [7]

Answer:

1. would be B.

2. would be D

3. May I ask if it can be multiple answers?

Explanation:

1. In coding a if statement has to follow if something is true or not. If we are talking about a if and then statement it will skip that block and move to the next block of the "then" part of the "if then" Statement if the first part is reported false

2. This is a easy one, so it has to be either a 3.25 GPA or higher or they have to have either 100 hours or more.

3. waiting for a comment back :)

4 0
4 years ago
Other questions:
  • Which sparkline type is best for displaying trends in data changes over time?
    11·1 answer
  • Which of the following is the largest disadvantage of hydropower?
    8·2 answers
  • An administrator needs to set up an authentication server for users connecting to a network through a VPN. What kind of server c
    10·1 answer
  • ----------HELP WITH 3 QUESTIONS FOR 30 POINTS!!!---------
    6·1 answer
  • Communication of a message between two processes implies which of the following? (A) Synchronization (B) Atomic operation (C) Bl
    11·1 answer
  • Select the correct answer.
    7·2 answers
  • Who is your favorite person from squid game?
    13·2 answers
  • How do you declare variables in c program
    14·1 answer
  • WILL GIVE BRAINLIEST!! NO LINKS!!!
    12·2 answers
  • What will help the programmer understand what’s going on in the program?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!