using JAVA create an arry using an initializer list with val

using JAVA:

create an arry using an initializer list with values:

4 8 1

2 3 7

call a method: printMaxfromRow

The printMax method should:

find the highest value in each row

Print the message \"The highest value in row 0 is 8\"

                              \"The highest value in row 1 is 7\"

Solution

MaxRowTest.java


public class MaxRowTest {

  
   public static void main(String[] args) {
       int a[][] = {{4,8,1},{2,3,7}};
       printMaxfromRow(a);
   }
   public static void printMaxfromRow(int a[][]){
       for(int i=0; i<a.length; i++){
       int max = a[i][0];
       for(int j=0; j<a[i].length; j++){
           if(max < a[i][j]){
               max = a[i][j];
           }
       }
       System.out.println(\"The highest value in row \"+i+\" is \"+max);
       }
   }

}

OUtput:

The highest value in row 0 is 8
The highest value in row 1 is 7

using JAVA: create an arry using an initializer list with values: 4 8 1 2 3 7 call a method: printMaxfromRow The printMax method should: find the highest value

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site