Hey guys,
Working on a project to calculate the standard deviation of an array. Instructions call for a program that will allow the user to enter a list of test scores with 999 as a sentinel value. Then a method calcStDev is invoked with the scores array as a parameter and should return the standard deviation. That is what I need help with. Writing the method calcStDev.
Here is my code:
import java.util.Scanner;
public class standardDeviation
{
public void arrayBuilder()
{
Scanner keyboard = new Scanner(System.in);
System.out.println("\fHow many numbers do you want to enter? If you are unsure, enter an abnormally large number, and enter 999 when done.");
int num = keyboard.nextInt();
int count = -1;
int i = 0;
int j=0;
int del = 999;
int sum = 0;
int [] grades = new int[num];
System.out.println("Enter the " + num + " numbers now.");
for (i = 0; i < grades.length; i++)
{
grades[i] = keyboard.nextInt();
count++;
if (grades[i]==999)
break;
}
System.out.println("You have entered: " + count + " number(s)");
//copy old array to new array(grades2), getting rid of all the 0's and the 999
int [] grades2 = new int[(count)];
System.arraycopy(grades, 0, grades2, 0, grades2.length);
System.out.println("These are the numbers you have entered."); //print the array out with no 999 or 0s attached
for (i = 0; i < grades2.length; i++)
System.out.print(grades2[i] + " ");
}
public static void calcStDev(int [] grades2)
{
}
}
Please help me out! Thanks!