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]
2 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]2 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
Vkq-jnfi-uif se-x fun girls joi-n mee-t usin-g this cod_e​
liberstina [14]

Answer:

Why?

Explanation:

7 0
2 years ago
What is a multipurpose network device?
exis [7]

Answer:

A switch connects multiple devices to a network. ... devices are usually integrated into a multipurpose network device

7 0
3 years ago
Sara is a college student studying accounting. She uses a laptop daily for personal and course work. What data might Sara have o
polet [3.4K]

Answer:

Sara: Personal data

Jorge : Personal data + official data.

Wanda: Personal data + students data

Carl: Personal data + official data

Explanation:

Personal data could contain pictures, social security numbers, banking transactions details, passwords, credit card information etc.

Jorge's official data could contain information about various sources that he gets his news from. It could contain password information about his official email. And he connects to the office network, he might pose a threat to the entire network if his PC is infected.

Wanda could leak the student's information. She could also leak her social security numbers, bank details, organization's details etc.

Carl could leak company's information. He can avoid it by staying away from public networks. Installing anti-virus. He should also take great care while accessing various sites and never download harmful files over the internet.

8 0
3 years ago
Mary is a big fan of tropical fish. She has a few tanks of fish at home. To maintain a healthy environment for the fish, she nee
astra-53 [7]

Answer:

Answered below

Explanation:

# Program is written in Python programming language

conditioner_in_ml = 0

width = float(input("Enter width in inches: "))

height = float(input("Enter height in inches: "))

length = float (input("Enter length in inches: "))

#Calculate the volume

volume = width * length * height

#Calculate the amount of conditioner per 100 #cubic inches of volume

conditioner_in_ml = volume/ 100

print("The amount of conditioner required for $volume cubic inches is $conditioner_in_ml ml")

7 0
2 years ago
An experimenter discovers that the time for people to detect a string of letters on a computer screen is 400 milliseconds, and t
nadya68 [22]

Answer:

The correct answer to the following question will be Option D (Subtractive method ).

Explanation:

  • This approach essentially requests a participant to construct two activities that are already in almost every way similar, except for a mental process that is assumed to also be included in any of the activities although omitted in another.
  • This method will be much more valuable when deciding the period for phonemic awareness, despite text-string identification.

The other three options are not related to the given scenario. So that Option D is the right answer.

3 0
3 years ago
Other questions:
  • You can use predesigned, formatted files called _____ to create new worksheets quickly.
    13·1 answer
  • 5. How should you use LinkedIn Answers as a professional?
    8·1 answer
  • Which statement best describes the Tell Me feature in PowerPoint 2016?
    8·1 answer
  • In paragraph form, explain and describe at least three common situations in which you would yield the right-of-way.
    5·1 answer
  • These data provides the responses of 10 students in class A and in class B who were asked how many hours they slept lastThese da
    6·1 answer
  • If you give an actual answer I'll give brainliest​
    13·2 answers
  • What is an example of a device that commonly use Linux today
    7·2 answers
  • What is operating system​
    10·2 answers
  • Need help ASAP.<br> I am so lost.
    5·1 answer
  • Clara works behind a computer all day. She gets a lot of headaches, and her eyes have been hurting her lately. Her doctor diagno
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!