Discover answers to your most pressing questions at Westonci.ca, the ultimate Q&A platform that connects you with expert solutions. Experience the ease of finding quick and accurate answers to your questions from professionals on our platform. Experience the ease of finding precise answers to your questions from a knowledgeable community of experts.
Sagot :
Answer:
Explanation:
The following code is written in Java and creates the two methods as requested each returning the desired double[] array with the averages. Both have been tested as seen in the example below and output the correct output as per the example in the question. they simply need to be added to whatever code you want.
public static double[] rowAvg(int[][] array) {
double result[] = new double[array.length];
for (int x = 0; x < array.length; x++) {
double average = 0;
for (int y = 0; y < array[x].length; y++) {
average += array[x][y];
}
average = average / array[x].length;
result[x] = average;
}
return result;
}
public static double[] colAvg(int[][] array) {
double result[] = new double[array[0].length];
for (int x = 0; x < array[x].length; x++) {
double average = 0;
for (int y = 0; y < array.length; y++) {
average += array[y][x];
}
average = average / array.length;
result[x] = average;
}
return result;
}


We hope this information was helpful. Feel free to return anytime for more answers to your questions and concerns. Thanks for using our platform. We aim to provide accurate and up-to-date answers to all your queries. Come back soon. Discover more at Westonci.ca. Return for the latest expert answers and updates on various topics.