C++ Lab Help

closed account (Diz60pDG)
I was given an assignment for a computer science lab, but am very confused by the problem.


Write a program that calculates the average of a stream of positive numbers. The
user can enter as many positive numbers as they want, and they will indicate that they are finished by entering a negative number. For this program, treat zero as a positive number, i.e., zero counts as a number that goes into the average. Of course, the negative number should not be part of the average. You must use a function to read in the numbers, keep track of the running sum and count, compute the average, and return the average to the main() function. 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.
The main() function must print the average (which was returned from your function), and then ask the user if they want to repeat the entire process. The user should be allowed to repeat the process as many times as they wish. This means you will have a loop in your main() function that instructs the user what to do, calls your average function, reports the result, and finally asks the user if they want to calculate another average for a different set of numbers.


Any help at all would be great, thanks.
The instructions seem clear.
We're not going to write the program for you.
Post what you have so far and where you're stuck and we will try to help.

Topic archived. No new replies allowed.