Master Computers and Technology with Fun Quizzes & Brain Teasers!

You are interested m computing the average acid level of coffee served by local coffee shops. You visit many coffee shops and dip your pH meter into samples of coffee. Unfortunately, your pH meter sometimes produces false readings. So you decide to disregard the single reading that is most distant from the average. Write a program that reads the data into an array. Use a negative value to signal the end of data. Compute the average of all the data by summing all the values and dividing by the number of values. If there are two or more values, scan through the array to find the value that is farthest (in either direction) from that average and compute an average that does not include this value by subtracting this value from the previously computed sum (If the most distant value occurs m the data more than once, that is OK Just subtract it from the sum once) If all the values are the same the average will not change, but do the above step anyway. Print the new average. If there is only one value, skip the above step (the average win be just the single value entered.) If there are no values (if the first value entered was negative) exit with an error message and without printing an average. Allow up to 100 pH values. The array will be an array of doubles, use double precision computation Here is a run of the program: sample 1: 5.6 sample 2: 6.2 sample 3: 6.0 sample 4: 5.5 sample 5: 5.7 sample 6: 6.1 sample 7: 7.4 sample 8: 5.5 sample 9: 5.5 sample 10: 6.3 sample 11: 6.4 sample 12: 4.0 sample 13: 6.9 sample 14: -1 average: 5.930769230769231 most distant value: 4.0 new average: 6.091666666666668