Question: write the Java programs that use methods and two-dimensional arrays. Problem 1: Complete the following java program which creates a two-dimensional array of 36


write the Java programs that use methods and two-dimensional arrays. Problem 1: Complete the following java program which creates a two-dimensional array of 36 (6 X 6) elements. The program then should do the following: 1. Initialize the elements of the array to random numbers between 0 and 100. 2. Display the content of the array in the form of a matrix. 3. Display the sum of elements of the array by columns. 4. Find and display the column number that has the largest sum. 5. Calculate and display the average of all the numbers. 6. Display the smallest element and its location in the array. public class MultiDimensionalArrayDemo { } public static void main(String[] args) { int[][] numbers = new int [6] [6]; int column = 0; initializeArray (numbers); System.out.println("The two-dimensional array of 6 by 6 random numbers is:"); displayArray (numbers); System.out.println("The sum of elements of the array by columns is: "); System.out.println(); int[] colsum = SumByColumn(numbers); //displaying the sum of elements by columns for(int i: colsum) { System.out.printf("%d", 1); } System.out.println(); System.out.println(); column colwith Largestsum(colsum); System.out.println("The column column has the largest sum of colsum[column]); System.out.printf(" The average of the array elements is %.2f ", getAverage (numbers)); displaySmallestAnd Location (numbers); Sample Outputs: The two-dimensional array of 6 by 6 random numbers is: 43 12 67 9 22 45 72 8 65 95 80 75 98 82 26 35 19 45 3 74 69 58 10 39 4 84 5 4 93 40 9 34 94 98 71 45 The sum of elements of the array by columns is: 430 261 277 204 173 387 The column e has the largest sum of 430 The average of the array elements is 48.11 The smallest element is 3 and is located in row 2 and column 3 84 83 83 79 67 27 The two-dimensional array of 5 by 6 random numbers is: 42 69 34 95 37 76 1 20 27 1 82 12 79 59 14 2 97 29 97 96 93 63 56 98 17 25 9 1 71 1 The sum of elements of the array by columns is: 347 340 482 298 220 139 The column 2 has the largest sum of 482 The average of the array elements is 50.72 The smallest element is 1 and is located in row 3 and column 1 Hand In: Make a folder named lab7_yourname containing the source code file, zip the folder and submit the zipped file to BrightSpace. Rubrics: Program: [2 marks] Presentation and Style: Readability, descriptive identifier, indentation, bracket placement, internal documentation (comments), use of appropriate constants [18 marks] Correctness: Program works without bugs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
