# Thread: standard deviation and mean for an array

1. Member
Join Date
Mar 2008
Posts
8
Rep Power
0

## standard deviation and mean for an array

hey everyone, i just started doing arrays and the program i'm trying to create is supose to take 8 random numbers from the user then calculates the standard deviation, and the mean and provide the standard scores, right now i'm have 6 errors because of the array. The error are are saying ; epected at the end of the method, but i did that and it doesn work. if you can help if would be greatly appreciated!!! :)
here's my code do far
PHP Code:
```import java.util.Scanner;
public class Statistics
{
public static void main(String[] args)
{

Scanner keyboard= new Scanner(System.in);
int Mean = 0;
double SD= 0.0;
int Count= 0;
System.out.print("How many numbers will you be entering? ");
int NumAmount = keyboard.nextInt();

System.out.println("Thank you. Please enter the " + NumAmount + " values below:");

GetNumbers(NumAmount);
int ListNum= GetNumbers(NumAmount);
double [] values = new double [NumAmount];

StanDev(values, NumAmount);
System.out.println("Statistics for the given numbers:");
}

static int GetNumbers(int NumAmount)
{
for (int n =0; n<=NumAmount;n++)
{
int [] values = new int [NumAmount];
Scanner keyboard= new Scanner(System.in);
int numbers = keyboard.nextInt();
System.out.println(numbers);
values [n]=numbers;
}

static double StanDev(double values,int NumAmount)

{
for(int i = 0; i < NumAmount; i++)
{
sum += values[i];
double mean = sum / NumAmount;
double sq_diff_sum = 0;
}

for(int i = 0; i <NumAmount ; ++i)
{
double diff = values[i] - mean;
sq_diff_sum += diff * diff;

}
double deviance= sq_diff_sum / n;
return sqrt(deviance);

}
}
}```

2. Please check those braces that were not paired....

specially at GetNumbers() and StanDev() method....

3. Java doesn't allow also to compile a method inside a method.

4. And also you have used some members without declaring. Careful about adding parenthesis in the code. That's the major issue you have comes with.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•