Question: Write a complete C++ program called average.cpp that does the following. First it reads three integers and reports the median of those three integers. Next,

Write a complete C++ program called average.cpp that does the following.

First it reads three integers and reports the median of those three integers.

Next, it reads integers until it reads −1. It reports the mean of all of those integers, excluding the −1 at the end.

Example 1

If the input is

3 9 5 4 5 8 20 25 -1
then your program should say:

The median of (3, 9, 5) is 5.
The mean of (4, 5, 8, 20, 25) is 12.40
Example 2

If the input is

3 6 3 2 4 6 -1
then your program should say:

The median of (3, 6, 3) is 3.
The mean of (2, 4, 6) is 4.00.

Step by Step Solution

3.46 Rating (159 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Below is a C program named averagecpp that performs the tasks as outlined in your question The program reads three integers calculates the median then ... View full answer

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 Programming Questions!