Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Objectives To perform while (or do-while) loops. To integrate conditionals into while loops. To translate a simple flowchart into a program. Prerequisites Do this problem

Objectives

To perform while (or do-while) loops.

To integrate conditionals into while loops.

To translate a simple flowchart into a program.

Prerequisites

Do this problem after you have completed the previous iteration problems.

Description

Write a program (aboveThreshold.scala) that reads in a value (integer) N, a threshold (double) T, and a list of N (double) numbers and then outputs the amount of numbers that were above the threshold. (Observe that "equal to" is NOT "above.")

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.

How many numbers should I read? > 5 What is the threshold? > 2.5 Please enter 5 numbers. > 1.2 > 3.2 > -2.8 > 2.5 > 5.6 There were 2 values above the threshold. 

Input

Here is just a sample input to the program.

5 2.5 1.2 3.2 -2.8 2.5 5.6 

Output

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

How many numbers should I read? What is the threshold? Please enter 5 numbers. There were 2 values above the threshold. 

Hint

For this program, you should translate the attached solution (aboveThreshold.png) presented as a flowchart into Scala. Note that this will require you to have an if-statement inside a while loop.

https://s3.amazonaws.com/mimirplatform.production/projects/badd0144-3f7a-4dc4-86c0-e9e4b21744f3/description_files/aboveThreshold.png

Need in scala

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored 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

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: KROENKE DAVID M.

1st Edition

8120322258, 978-8120322257

More Books

Students also viewed these Databases questions

Question

What is your assessment of the value of the 1986 False Claims Act?

Answered: 1 week ago

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago