In Java In a 2D Array aDisplay the row and column with the h
In Java:
In a 2D Array:
a.)Display the row and column with the highest average.
b.)Display the row and column with the lowest average
Solution
TwoDimArray.java
import java.util.Scanner;
public class TwoDimArray {
   public static void main(String[] args) {
        //Declaring double type two dimensional array
        double average[][]=new double[4][4];
       
        //Declaring variables
        double min,max;
        int min_row = 0,min_column=0,count=0;
        int max_row=0,max_column=0;
       
        /* Scanner class object is used to read
        * the inputs entered by the user
        */
        Scanner sc=new Scanner(System.in);
       
        /* This nested for loop will get the average values
        * entered by the user and populate them into an array
        */
        for(int i=0;i<4;i++)
        {
            for(int j=0;j<4;j++)
            {
                //Getting the average values entered by the user
                System.out.print(\"Enter Average \"+(++count)+\":\");
                average[i][j]=sc.nextDouble();
            }
        }
       
        /* Assining the first element of two dimensional
        * array to the min an max variables
        */
        min=average[0][0];
        max=average[0][0];
       
        /* This loop will minimum and maximum average
        * values and also at what positions in the array
        */
        for(int i=0;i<4;i++)
        {
            for(int j=0;j<4;j++)
            {
                /* This block will get the minimum average value
                * in the array and also at what position
                */
 if(average[i][j]<min)
 {
    min=average[i][j];
    min_row=i;
    min_column=j;
 }
                /* This block will get the maximum average value
                * in the array and also at what position
                */   
 if(average[i][j]>max)
 {
    max=average[i][j];
    max_row=i;
    max_column=j;
 }
            }
        }
       
        //Displaying the results
        System.out.println(\"The Highest Average \"+max+\" found at \ Row \"+max_row+\"\ Column \"+max_column);
        System.out.println(\"The Lighest Average \"+min+\" found at \ Row \"+min_row+\"\ Column \"+min_column);
}
}
_____________________
Output:
Enter Average 1:78.9
 Enter Average 2:90.7
 Enter Average 3:87.6
 Enter Average 4:67.6
 Enter Average 5:56.6
 Enter Average 6:45.5
 Enter Average 7:88.7
 Enter Average 8:92.5
 Enter Average 9:69.6
 Enter Average 10:56.4
 Enter Average 11:55.5
 Enter Average 12:77.7
 Enter Average 13:68.2
 Enter Average 14:54.2
 Enter Average 15:95.3
 Enter Average 16:81.1
 The Highest Average 95.3 found at
 Row 3
 Column 2
 The Lighest Average 45.5 found at
 Row 1
 Column 1
______Thank You


