Write a complete C++ program called average.cpp that does the following. First it reads three integers and
Fantastic news! We've Found the answer you've been seeking!
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, 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.
Related Book For
Data Structures and Algorithm Analysis in Java
ISBN: 978-0132576277
3rd edition
Authors: Mark A. Weiss
Posted Date: