I am having problems with arrays.
I have written a code to add the sum of all the numbers in an array and I have to test it from the main by calling on previous arrays. But I can't figure out where I am going wrong.
Scanner stdin = new Scanner(System.in);
double [] scores = new double[5];
System.out.println(scores.length);
for(int i = 0; i < scores.length; i++)
{
System.out.println("Please enter " + i + "th array value");
scores[i] = stdin.nextDouble();
}
double sums = sumArray(scores);
System.out.println(sums);
}
public static double sumArray( double[] dArray)
{
double sum = 0;
for(int i = 0; i <= dArray.length; i++)
{
sum = sum + dArray[i];
}
return (sum);
}
}