I am really confused by this problem. PLEASE HELP

Write a program that reads a set of floating point data values from the input. When the user indicates the end of the input, print out the count if the values, the average, and the standard deviation. The average of a data set is x1,......,xn is

t = Σxi/n

where Σx1 = x1+...+xn is the sum of the input values. The standard deviation is:

s=Math.sqrt(Σxi^2 - (1/n)*(Σxi)^2/n-1)

my professor asks me to Create a method in the class Mymath to print out the count of values, the average, and the standard deviation. Use the numerically less stable formula to find the standard deviation.

and this is what the output should be:

1
2
3
4
5
6
-1

Count of values: 6
Average: 3.50
Standard Deviation: 1.87

Recommended Answers

All 6 Replies

So which part are you confused about? Reading in the values? Calculating the formulas? The formulas are standard formulas, so if you don't get them, just look up those terms on google and you'll find plenty of explanations. Your professor didn't make those up. And to read in the values, you can make a Scanner. Test each value read in; if it is -1, stop reading in values, and do not include the -1 value in your calculations. So you'll basically be using a while loop to read in all the values, then adding them to an ArrayList<Integer>.

im just confused on how to do it. i guess i need a jump start thats all.

  1. Get the count
  2. Calculate the sum
  3. From the count and the sum, calculate the average.
  4. From the average, get each deviation (error).
  5. Square each deviation (squared error).
  6. Add up the squares (sum of squared errors).
  7. Divide by (count - 1) (mean squared error. count - 1 is degrees of freedom).
  8. Take the square root.
  9. You now have the standard deviation.

Slightly different formula/method than the one you listed, but if you do some math, I imagine you'll find that they are equivalent and will give identical results.

WRIGHT A PROGRAM IN C WHICH REQUEST SCORES STORES THEM IN AN ARRAY , THEN IT CALCULATES THE MEAN, Deviations FROM MEAN, STD DEVIATION AND THEN IT PRINTS THE THREE(MEAN, AVERAGE, DEVIATIONS, STD DEVIATION.)

WRIGHT A PROGRAM IN C WHICH REQUEST SCORES STORES THEM IN AN ARRAY , THEN IT CALCULATES THE MEAN, Deviations FROM MEAN, STD DEVIATION AND THEN IT PRINTS THE THREE(MEAN, AVERAGE, DEVIATIONS, STD DEVIATION.)

Don't yell( meaning don't use capitals) we are not DEAF.
Also start a new thread.
Also this is a java forum not a C forum.
Also post some code. Don't expect someone to give you the answer. If you don't know where to start, explain specifically what is your problem

On Nov. 7th VernonDozier has clearly and correctly indicated the steps in writing a code to calculate. Please following the instruction write your own program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.