Question: In Class exercise 7 5/9 Refer to TwoDArray in files (InClassEx, CH7) // Fill a 2D (5x10) array with random values(0-50) // Determine the max.
In Class exercise 7 5/9 Refer to TwoDArray in files (InClassEx, CH7)
// Fill a 2D (5x10) array with random values(0-50)
// Determine the max. integer value in this array
// First output the array (5 rows, 10 columns)
// Then output the max value found
// and the last place (row, column) this max value
// was found
// Remember to output your name to console
public class TwoDArrayMax {
//Up load one file to canvas: TwoDArrayMax.java
here is example:
// In Class Example: 2 D Arrays import java.util.Arrays;
// In class example of 2 dimensional array public class TwoDArray {
public static void main(String[] args) { // Initialize 2d array int [][] array= new int[4][5]; array=new int[][] { {2,3,4,7,9}, //row 1 {0,7,7,9,3}, //row 2 {8,9,3,3,1}, //row 3 {1,1,1,1,1} }; //row 4 System.out.println("array address="+array); //Each array[i] points to a row address which is // the location of the four "1" Dimension arrays // all four of which make up the 2D array System.out.println("array[]row address= "+array[0]+" " +array[1]+" "+array[2]+" "+array[3]); // Print out array, the rows' values // for (int i=0;i<4 ;i++){ system.out.println(arrays.tostring(array[i])); }>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
