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.

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

  2. 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

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!