fred rosenberger wrote:
Why do you have "sum = sum + data" on line 26? At this point, you know data must be zero, so this is an unnecessary line.
Finally, you get the square of the total because that is exactly what this code says to do:
sum2 = Math.pow(sum, 2);
What you need to do is compute the square of each number as you get it, and add that to your sum2 (and PLEASE choose a better name, like "sumOfSquares").
I also need to calculate the mean and by using that I was able to do so.
so please excuse me for not thinking to use a for loop in this problem.
Paul Clapham wrote:Then perhaps your problem is that you read in the numbers that the user inputs, but you don't store them anywhere so that you can go through them a second time to calculate the standard deviation?
Peter Haugen wrote:So, I have tried to take your advice about sitting down and writing everything out. This is what I have come up
Please forgive my lack of knowledge here, but I thought that "data" stored them...
Peter Haugen wrote:So, I have tried to take your advice about sitting down and writing everything out. This is what I have come up... At this point I am having issues calculating the deviation... Could anyone please help?
Peter Haugen wrote:Thanks everyone for the help with this problem.