Hello my objective for this program is to take a data file for input
and find the total numbers on the field, the average, and the sum
and output it to another file.
this is what i have but for some reason it is not working..
Well, I can't see anything that could cause that, but you should know that the way you're calculating the average is incorrect. You're giving much more weight to the first values than to the last ones.
totalVal has all the numbers added up
and numOfData has the amount of numbers I added up. Wouldn't the average be the total divided by the amount numbers added up?
Never mind. I thought because it was inside the loop you were doing something else, which is a common mistake.
Yes, the way you're doing it will give the correct result, but there no reason why it needs to be inside the loop.