Reference no: EM13865132
Use a nested for loop to compute the average of the rows in each double. The code below works to populate the 2D array however cannot yet compute and print the averages.
TEXT QUESTION: Write a complete Java program called Scorer that declares a 2-dimensional array of doubles called scores with three rows and three columns. Use a nested while loop to get the nine (3 x 3) doubles from the user at the command line. Finally, use a nested for loop to compute the average of the doubles in each row and output these three averages to the command line.
public static void main(String[] args) {
Scanner userInput = new Scanner(System.in);
int row;
int col;
final int NUM_ROWS = 3;
final int NUM_COLS = 3;
// Score array 3x3 doubles
double [][] ScoringMatrix = new double [NUM_ROWS][NUM_COLS];
ScoringMatrix[0] = new double[3];
ScoringMatrix[1] = new double[3];
ScoringMatrix[2] = new double[3];
for(row = 0; row < NUM_ROWS; row++) {
for(col = 0; col < NUM_COLS; col++) {
System.out.println("Enter a double: ");
ScoringMatrix[row][col] = userInput.nextDouble();
}}
for(row = 0; row < NUM_ROWS; row++) {
for(col = 0; col < NUM_COLS; col++) {
/* Need code to average the rows and print the results of the mean calc */
}}
System.out.println("");
return;
}