Here is the assignment:
- Create an array to store 10 numbers.
- Using a loop, prompt the user to enter 10 grades and store them in the array.
- Then make another loop that prints the numbers in the array out backwards and adds up the numbers in the array.
- Use the sum to calculate the average of the numbers. Print out the average of the numbers.
My code so far:
public static void ar() {
double[] grades = new double[10];
Scanner kb = new Scanner(System.in);
for(int i=0; i < grades.length; i++)
grades[i]=kb.nextDouble();
double sum=0;
for(int j=10; j > grades.length; j--)
sum=sum+grades[j];
double ave = sum/10;
System.out.println(ave);
}
However it only prints 0.0 ten times.