In Java : Find the lowest average of a row in a 2D Array This my code for findin
ID: 3780141 • Letter: I
Question
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));
Explanation / Answer
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
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.