Question
write a program ( in C++) that reads a specified number of real numbers from the user and prints their average. The first number input
write a program ( in C++) that reads a specified number of real numbers from the user and prints their average. The first number input by the user will be an integer that specifies how many numbers are to be averaged. The rest of the input will be the floating point numbers to be averaged.Your output should be accurate to three decimal places.
Part 1: NESTED LOOP When you run an experiment, you often run it multiple times. In that case you will probably want to perform the same calculation on the data set from each experiment. You may also want to add some error checking to the program, to make sure that you do not enter any outlandish values.
In this part you will add two features to your program that accomplish these two tasks:
the user is able to enter an arbitrary number of data sets, and you need to average each data set. Each data set starts with the number of observations, entered as floating point numbers, and then the observations. When you encounter a data set that starts with the number 0, you will exit the program. You will need to add an outer while loop (i.e., a while loop that surrounds your for loop) to your program.
the size of the data set must be between 1 and 10 inclusive. You should continually prompt the user for a valid data size until the user enters either 0, meaning that you should exit the program, or an integer between 1 and 10. Use a do while to implement this prompt (you may need to put this prompt in two different places in your program).
For this last phase you are now to add an overall average for the data sets input. To do this you will print the average of all the data sets at the very end of the program except you will throw out the lowest and highest datasets averages.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started