I have the answer for the first four parts would please help

I have the answer for the first four parts, would please help with the last two parts please: 5. The class named Strict should also have a method public static void display(int[][] m1, int[][] m2) that displays only those values of the arrays that are odd in rectangular form (row by row for each array.) You may assume the values entered are between 0 and 99 for formatting purposes. Make it pretty! 6. The class named Strict should also have a method public static boolean silly(int[][] m1, int[][] m2) that returns true if the two arrays have all numbers satisfying 1 < numbers <=10 and returns false otherwise.

Solution

Please find my implementation.

Please let me know in case of any issue.

public static boolean silly(int[][] m1, int[][] m2){

       // to check the status whether numbers 0-9 is present or not in m1

       boolean[] status1 = new boolean[11]; // by default all entries are false

       for(int i=0; i<m1.length; i++){

           for(int j=0; j<m1[i].length; j++){

               if(m1[i][j] >=1 && m1[i][j] <=10) // if entry is in range 1-10, then mark true

                   status1[m1[i][j]] = true;

           }

       }

       boolean s1 = true;

       for(int i=1; i<=10; i++) // if at least one entry is false then it makes s1 false

           s1 = s1 && status1[i];

       // checking in m2

       // to check the status whether numbers 0-9 is present or not in m2

       boolean[] status2 = new boolean[11]; // by default all entries are false

       for(int i=0; i<m2.length; i++){

           for(int j=0; j<m2[i].length; j++){

               if(m2[i][j] >=1 && m2[i][j] <=10) // if entry is in range 1-10, then mark true

                   status2[m2[i][j]] = true;

           }

       }

       boolean s2 = true;

       for(int i=1; i<=10; i++) // if at least one entry is false then it makes s1 false

           s2 = s2 && status2[i];

      

       return s1 && s2;

   }

I have the answer for the first four parts, would please help with the last two parts please: 5. The class named Strict should also have a method public static
I have the answer for the first four parts, would please help with the last two parts please: 5. The class named Strict should also have a method public static

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site