Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives To perform while (or do-while) loops. To translate a simple flowchart into a program. Prerequisites Do this problem after you have completed the Conditional

Objectives

To perform while (or do-while) loops.

To translate a simple flowchart into a program.

Prerequisites

Do this problem after you have completed the Conditional Expressions and are ready for Iterations using while loops.

Description

Write a program (sumIt.scala) that reads in a list of numbers until a 0 is entered and outputs the sum of the numbers entered.

Sample Run

The following is a sample run. It includes both input and output. For clarity, the input lines are preceded by the symbol > and the shell command (to start the program) is preceded by the symbol $. A sample input and output are separated afterwards.

$ scala sumIt.scala Please enter a list of numbers terminated by a 0. > 1 > 2 > 3 > 4 > 5 > 0 15 

Input

Here is just a sample input to the program.

1 2 3 4 5 0 

Output

Here is just a sample output to the program. Notice that the prompts are part of the program's output.

Please enter a list of numbers terminated by a 0. 15

need it in scala

https://s3.amazonaws.com/mimirplatform.production/projects/0f2f2ed5-87da-46aa-b893-993131923262/description_files/sumIt.png

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

what is the use of gridlines and legends in a chart

Answered: 1 week ago