The standard deviation of a list of numbers is a measure of how much the numbers deviate from the average. If the standard deviation is small, the numbers are clustered close to the average. If the standard deviation is large, the numbers are scattered far from the average. The standard deviation of a list of numbers n1, n2, n3, and so forth is defined as the square root of the average of the following numbers:
(n1 - a)^2, (n2 - a)^2, (n3 - a)^2, and so forth.
The number a is the average of the numbers n1, n2, n3, and so forth. Define a static method that takes a partially filled array of numbers as its argument and returns the standard deviation of the numbers in the partially filled array. Since a partially filled array requires two arguments, the method will actually have two formal parameters, an array parameter and a formal parameter of type int that gives the number of array positions used. The numbers in the array will be of type double. Write a suitable test program for your method.
this is my program so far with driver
public class Deviations
{
public static double standard(double[] a, int n)
{
double average = 0;
for(int i = 0; i < a.length; i++)
average = average + a[i];
if(n > 0)
{
return (average/n);
}
else
{
System.out.println("ERROR: Can't average 0 numbers.");
return 0;
}
}
}
// driver program
import java.util.Scanner;
public class DeviationsDemo
{
public static void main(String[] args)
{
int n;
Deviations deed = new Deviations();
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter length of the array.");
n.standard(keyboard.nextInt());
double[] a = new double[15];
}
}
if anyone can help me get this right according to the directions i would really appreciate it
i am confused on how to do this, but i am still thinking this through
thank you for any help