
David W. answered 11/04/21
Experienced Prof
repetition -- "enter as many numbers as they want" and "must have a way for the user to stop entering values"
relational operators -- "all numbers must be greater than zero"
input validation -- "all numbers must be greater than zero"
FOR THE LOGIC OF THE PROGRAM:
"The lowest number was:" - Remember the first valid number; reset if any later valid number is smaller.
"The highest number was:" - Remember the first valid number; reset if any later valid number is larger.
"The number of values entered was:" Count the valid numbers.
"The average of the numbers was:" The method used depends on the data. For "as many numbers as they want," use METHOD 2.
METHOD 1: Initially set SUM=0, add each valid number to it as they are validated, divide by count of valid numbers. Note: The SUM may get VERY LARGE (and overflow variable maximum).
METHOD 2: Initially set SUM=0, AVERAGE=0. When a valid number is input, it adds to the AVERAGE (note: all valid values are positive) by:
Variables that are stored during the computation of the average:
N = 0
avg = 0
Examples of METHOD 2 are helpful in understanding it.
** Please contact me for tutoring on this topic (and for useful executable flowchart tool).
For each new value: V
N=N+1
a = 1/N
b = 1 - a
avg = a * V + b * avg