I'm trying to write a code where I need to use three methods. The first method must use a nested while loop to create a multidimensional array that is 3x3 and will get the values from the command line. The second method needs top use nested for loops in order to calculate the average of the doubles in each row. And the final method needs to shows the result of those averages. I'm currently getting cannot final symbol error. What did I do wrong?
I created the method fillArray to have the values from the user be stored. The return value is all the values entered at the command line.
import java.util.Scanner; public class Scorer {
public static void main(String[] args) {
fillArray();
System.out.println(scores);
}
public static double [][] fillArray(){
double [][] scores = new double [3][3];
Scanner scnr = new Scanner(System.in);
int col = 3;
int row = 3;
System.out.println("Enter your scores: ");
int i = 0;
while(i < scores[i].length){
int j = 0;
while(j < scores[i].length){
scores[i][j] = scnr.nextDouble();
j++;
}
i++;
}
return scores;
}
}
The code should allow for 3 values to be entered for each column and then be able to calculate the average of each rows values and have those results displayed back.