Question: 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: 1Q4: Highs and lows(Loop algorithms: Maximum/minimum) Instructions Today well carry on working

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!