Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q4: Highs and lows(Loop algorithms: Maximum/minimum) Instructions Today well carry on working through some common loop algorithms. Our second one will be finding both the

Q4: Highs and lows(Loop algorithms: Maximum/minimum)

Instructions

Today well carry on working through some common loop algorithms. Our second one will be finding both the maximum and minimum of a set of values.

Your task is to fix the code so that it does what is expected/described below.

Details

Input

The program reads in the following:

an integer values (unknown quantity, each on their own line)

followed by one empty line (empty string )

Hint: This input style should look familiar!

Processing

You are to find the maximum and minimum of the set of integers read in. To do this, you will make use of the following algorithms, which in this program will overlap:

Minimum value algorithm:

Read in a value (make sure to convert it to proper data type)

_Initialize minimum to this first value

_

Use while loop with looking for sentinel, each time through loop:

Convert the input value to proper data type

* _Decide if the value is less than the value held in **minimum**_ * _If it is, set **minimum** to this new value _ * Read in another value 

Maximum value algorithm:

Read in a value (make sure to convert it to proper data type)

_Initialize maximum to this first value

_

Use while loop with looking for sentinel, each time through loop:

Convert the input value to proper data type

Decide if the input value is greater than the value held in maximum

_If it is, set maximum to this new value

_

Read in another value

Output

Output the max/min of the values (done for you).

Sample input/output:

Input Output
3 1 4 7 5 Maximum: 7 Minimum: 1image text in transcribed

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_2

Step: 3

blur-text-image_3

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: David M. Kroenke, David J. Auer

14th edition

133876705, 9781292107639, 1292107634, 978-0133876703

More Books

Students also viewed these Databases questions

Question

What are you attached to?

Answered: 1 week ago