Question: I wrote a code that find average of 2d array list, after running the code, The error message says Averager2D.java:84: error: '.class' expected return
I wrote a code that find average of 2d array list, after running the code, The error message says
"""" Averager2D.java:84: error: '.class' expected return double; ^ 1 error"""""
Could you please let me know whats wrong with the code and could you fix it aswell?
public static double average(int[][] aa)
{
double total = 0;
int count = 0;
for (int i = 0; i for(int j =0; j < aa[i].length; j++){ int element = aa[i][j]; total = total + element; count++; } return count; } double average = total / count; //end code.. } Find the average of the even elements of a two-dimensional array and return it */ public static double averageEvens(int[][] aa) { double total = 0; int count = 0; for(int i=0; i < aa.length; i++){ for (int j =0; j < aa[i].length; j++){ int element = aa[i][j]; if(element %2==0){ total = total + element; count++; } } return double; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
