Ask your own question, for FREE!
Computer Science 23 Online
OpenStudy (anonymous):

1.Write a method that takes two integer number as a parameters such as M and N. This method should return a table with random numbers with the size of MxN. 2.Write an another method that take a table as a parameter and prints out table contents as appear in a table. 3.Write one more method that takes one table and one boolean as parameters. If this boolean variable is set to “true” this method returns the maximum number in the table, other case returns the minimum number. 4.Test these method with different numbers. #java

OpenStudy (anonymous):

1. int method(int a,int b) { int matrix[a,b] for(i=0;i<a;i++) { for(j=0;j<b;j++) printf("%d", a[i,j];}}} convert it into java using class

OpenStudy (anonymous):

I wrote 1 and 2question but i can't do the third one. public static int[][] numberToArray(int m, int n){ int[][] array=new int[m][n]; Random r=new Random(); //int number=r.nextInt(100); for(int i=0; i<m; i++){ for(int j=0; j<n; j++){ int number=r.nextInt(100); array[i][j]=number; System.out.print(array[i][j]+", "); } System.out.println(" "); } return array; } //Second question public static void print(int [][] array){ for(int i=0; i<array.length; i++){ for(int j=0; j<array[0].length; j++){ System.out.print(array[i][j]+" "); } System.out.println(" "); } }

OpenStudy (anonymous):

how can i do the 3. question

OpenStudy (anonymous):

private int getMinMax(int[][] table, boolean max){ if(max) return max(table); else return min(table); } private int min(int[][] table){ int tempMin = int[0][0]; for(int i = 0; i < table.length; i++) for(int j = 1; j < table[i].length; j++) if(table[i][j] < tempMin) tempMin = table[i][j]; return tempMin; } private int max(int[][] table){ int tempMax = int[0][0]; for(int i = 0; i < table.length; i++) for(int j = 1; j < table[i].length; j++) if(table[i][j] > tempMax) tempMax = table[i][j]; return tempMax; } //or private int getMinMax(int[][] table, boolean max){ if(max) return max(table); else return min(table); } private int min(int[][] table){ int tempMin = int[0][0]; for(int i = 0; i < table.length; i++) for(int j = 1; j < table[i].length; j++) if(table[i][j] < tempMin) tempMin = table[i][j]; return tempMin; } private int max(int[][] table){ int tempMax = int[0][0]; for(int i = 0; i < table.length; i++) for(int j = 1; j < table[i].length; j++) if(table[i][j] > tempMax) tempMax = table[i][j]; return tempMax; }

OpenStudy (anonymous):

THANKS

OpenStudy (anonymous):

?

OpenStudy (clalgee):

What do you believe the answer is?

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!