Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create statistics , in a sentinel-controlled loop: Write a program to read a list of non-negative numbers and then print out the largest integer, the

Create statistics, in a sentinel-controlled loop:

Write a program to read a list of non-negative numbers and then print out the largest integer, the smallest integer, and the average of all of the integers that were entered. The user indicates the end of the input by entering any negative sentinel value, and that value must not be used in finding the largest, smallest, and average values.

The average should be of type double so it is computed with a fractional part. Handle the case where the first value is the sentinel by printing an error message and not trying to calculate the average (which would cause a division by 0 runtime error).

If the user did not enter any 0 or positive integers, that is, if the first number they enter is negative, print this error message:

You did not enter any positive integers.

Otherwise print out the statistics this way, assuming the user entered 1 2 2 -1:

For the 3 numbers you entered the largest value = 1 the smallest value = 1 and the average is = 1.66666666666666667

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

More Books

Students also viewed these Databases questions

Question

Demonstrate how to use the Gaps Model for diagnosing and

Answered: 1 week ago

Question

Differentiate between hard and soft measures of service quality.

Answered: 1 week ago