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
A technician wants to update the organization's disaster recovery plans. Which of the following will allow network devices to be
Illusion [34]

Answer:B) Archives/backups

Explanation: Archive is the group of records of data that are saved for the future use.These are the historic data that is not currently used in the actual location .

Backup is the the the copy of the group of data that is not in the original form to be used in future. Thus the correct option is option(B).

Updating of the plans by the technician cannot be done through other given options because they don't hold the historic records of the data for the renewing of the plans.

6 0
3 years ago
The sum of the deviations of each data value from this measure of central location will always be zero. A. Median B. Standard de
JulijaS [17]

Answer:

C. Mean

Explanation:

Mean = (∑x_{i})/N

Median = central values when data is sorted

Mode = most repeated value

Standard deviation = \sqrt{sum(x_{i}-mean)^{2}/N}

In standard deviation, formula you may see that deviation is being calculated from the mean (central location). But here we take square of the value before adding all of them.

But if we just take sum(x - mean), it would be equal to zero.

<u>EXAMPLE</u>

Take 4, 9, 5 as data

mean = (4+9+5)/3 = 18/3 = 6

sum of deviations from mean = (4-6)+(9-6)+(5-6) = (-2)+(3)+(-1) = 0

8 0
3 years ago
Read 2 more answers
What cold, hard facts support your position?
Sladkaya [172]
Idk what is it?
a computer?
plz mark me as brainliest
6 0
3 years ago
Design an application for Bob's E-Z Loans. The application accepts a client's loan amount and monthly payment amount. Output the
Zepler [3.9K]

Answer:

Check the explanation

Explanation:

pseudo code:

Start

Declarations

LomMount as Double

MonthlyPay as Double

While-begin :condition,[ MontblyPay < LoanArnount] II( LoanAmount >0]

Begin

If monthlyPay < = LoanArnount

Display " MonthlyPay "

eIse

Display "LoanAmount"

End-if

LoanAmount = LoanAmount-MonthlyPay

End-while

Stop

7 0
3 years ago
Hi this is for computer and technology experts out there but can someone tell me why my dell computer charger wont work please h
exis [7]
It probably short circuited or something inside your computer hole is broken
7 0
2 years ago
Read 2 more answers
Other questions:
  • Write a C program to calculate monthly payment and print a table of payment schedule for a fixed rate loan.
    7·1 answer
  • Which partitioning method must you use for a 4-tb hard drive?
    13·1 answer
  • Using the lab's show ip sla statistics example, what does the failure count indicate about the web server?
    8·1 answer
  • Assuming that the actual process ids of the parent and child process are 2600 and 2650 respectively, what will be printed out at
    10·1 answer
  • What is one method that can be used to open the Microsoft Word application?
    8·1 answer
  • ___________ is a computer processor which incorporates the functions of a computer's central processing unit (CPU) on a single i
    15·2 answers
  • Which of the following is the Boolean logical operator for OR in C#?
    12·2 answers
  • Describe the procedure for creating a table or spreadsheet in a presentation slide.
    13·1 answer
  • What is data Communications​
    11·2 answers
  • if a user watches a video with event tracking three times in a single session, analytics will count how many unique events?
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!