In Java Find the lowest average of a row in a 2D Array This

In Java :

Find the lowest average of a row in a 2D Array

This my code for finding the max average

int maxRow = 0;
       int indexOfMaxRow = 0;
      
       double average = 0;
       for(int col = 0; col < a[0].length; col++){
           maxRow += a[0][col];
          
       }
      
      
       for(int row = 1; row < a.length; row++){
           int sum = 0;
          
           for(int col = 0; col < a[row].length; col ++){
               sum += a[row][col];
              
               if(sum > maxRow){
                   maxRow = sum;
                   indexOfMaxRow = row;
               }
           }
           average = a[row].length;
          
       }
       System.out.println(\"Row with max average is row \" + (indexOfMaxRow + 1) + \", \" + (maxRow / average));

Solution

could you explain the requirement clearly.So that I can exactly write the code for your requirement.

I didnt understand some thing like..what is the lowest average of a row in 2 D array??

The code you provided is not working properly to understood.No need of code .Just give me clear explanation.so that it will be easy for me to develop the code for that requirement.Thank You

In Java : Find the lowest average of a row in a 2D Array This my code for finding the max average int maxRow = 0; int indexOfMaxRow = 0; double average = 0; for

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site