Simple Standard Deviation Program without an Array

davemoosehead's Avatar, Join Date: Feb 2008
Newbie Member
I'm in an introductory Java course and our first assignment has me stumped. It will read a series of numeric scores (integers) until -1 is read, then calculate standard deviation. We also must determine the highest score, average, and other numbers. But the catch is no arrays. I don't know how to find standard deviation without recording down the set of numbers.

Just to make sure I have the right concept of SD, don't I first have to find the mean, and then subtract it from each score? Square each number and add them up, divide by n-1, then find the square root.

sqrt{ sigma[(x - xbar)^2] / n-1}
0
davemoosehead's Avatar, Join Date: Feb 2008
Newbie Member
ok i figured it out. a different formula can be used...

sqrt{ [ n(x1^2 + x2^2...) - (x1 + x2...)^2] / n(n-1) }

no need for array, thanks!
0
sandymalhotra's Avatar
Light Poster
Cooooolllll