Dear all,

I am trying to write a code that would take in an array of numbers(salaries) and then calculating the mean and standard deviance. The number of salaries is first asked from the user, therefore the number of elements in the array is not predefined. I have written the code, but it does not give me the right answer, please help me troubleshoot this problem

```
import java.util.Scanner;
public class Q4_Arrays{
public static void main(String [] a){
Scanner input= new Scanner (System.in);
System.out.println("Please enter the number of employees");
int noEmp = input.nextInt();
double [] salaries = new double [noEmp];
double Var=0;
double total= 0;
double sDev;
for (int i= 1; i<=salaries.length; i++){
System.out.println("Please enter Salary");
double Salary=input.nextDouble();
total= total + Salary ; }
double average = total/noEmp;
System.out.println("The average salary of your company is "+ average);
for (int i=1; i<salaries.length;i++)
{
Var = Var + (Math.pow(salaries[i] - average, 2)/salaries.length);
}
sDev= Math.sqrt(Var);
System.out.println("The standard deviation for this company's salaries is " + sDev);
}
}
```