Write a program that calculates the average of a stream of non-negative numbers. The user can enter as many non-negative numbers as they want, and they will indicate that they are finished by entering a negative number. For this program, zero counts as a number that goes into the average. Of course, the negative number should not be part of the average (and, for this program, the average of 0 numbers is 0). You must use a method to read in the numbers, keep track of the running sum and count, compute the average, and return the average to the main () method. Note that you must use a loop to do this, as you don't know how many numbers the user will enter ahead of time.
+1
Answers (1)
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a program that calculates the average of a stream of non-negative numbers. The user can enter as many non-negative numbers as they ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Home » Computers & Technology » Write a program that calculates the average of a stream of non-negative numbers. The user can enter as many non-negative numbers as they want, and they will indicate that they are finished by entering a negative number.