What is/are the dimension(s) of the array m? What is the length of the array r? What does r[2] represent? What does m[0].length stands for? Can you explain how the average was calculated? max) max =...


What is/are the dimension(s) of the array m?


What is the length of the array r?


What does r[2] represent?


What does m[0].length stands for?


Can you explain how the average was calculated?


1 import java.util.Scanner;<br>2<br>3 public class Pass2D {<br>public static void main(String[] args) {<br>5<br>// Get an array from the user<br>int[][] m = getArray();<br>7<br>8<br>// Display array elements<br>System.out.println(
max) max = element; 24 25 26 27 sum += element; } 28 29 30 //create a new array to be returned int[] c = new int[3]; c[0] = min; C[1] = max; 31 32 33 34 35 C[2] = sum; 36 37 return c; 38 } 39 40 // this method creates an array based on the user input 41 public static int[][] getArray() { // Create a Scanner Scanner input = new Scanner(System.in); System.out.println("Provide an integer for a number of rows: "); int row = input.nextInt((); 42 43 44 45 46 47 System.out.println("Provide an integer for a number of columns: "); int col = input.nextInt(); 48 49 // Create an arr int[][] m = new int[row][col]; System.out.println("Enter a " + m.length + "x" for (int i = 0; i < m.length;="" i++)="" for="" (int="" j="0;" j="">< m[i].length;="" j++)="" 50="" 51="" 52="" +="" m[0].length="" +="" "="" matrix="" and="" press="" enter:="" ");="" 53="" 54="" 55="" m[i][j]="input.nextInt();" 56="" 57="" input.close();="" 58="" 59="" return="" m;="" 60="" }="" 61="" }="" "/="">
Extracted text: 1 import java.util.Scanner; 2 3 public class Pass2D { public static void main(String[] args) { 5 // Get an array from the user int[][] m = getArray(); 7 8 // Display array elements System.out.println("\nYou provided the following array 9 10 + java.util.Arrays.deepToString(m)); 11 // Display array characteristics int [] r = findCharacteristics (m); System.out.println("\nThe minimum value is: " + r[0] + 12 13 14 ", the maximum value is: " + r[1] + ", the average is: " + r[2] * 1.0/(m.length * m[@].length)); 15 16 17 } 18 19 // this method finds array characteristics 20 public static int[] findcCharacteristics(int[][] m) { int min = m[0][0]; int max = m[0][0]; 21 22 23 int sum = 0; for (int [] arr : m) for (int element : arr) { if (element < min)="" min="element;" if="" (element=""> max) max = element; 24 25 26 27 sum += element; } 28 29 30 //create a new array to be returned int[] c = new int[3]; c[0] = min; C[1] = max; 31 32 33 34 35 C[2] = sum; 36 37 return c; 38 } 39 40 // this method creates an array based on the user input 41 public static int[][] getArray() { // Create a Scanner Scanner input = new Scanner(System.in); System.out.println("Provide an integer for a number of rows: "); int row = input.nextInt((); 42 43 44 45 46 47 System.out.println("Provide an integer for a number of columns: "); int col = input.nextInt(); 48 49 // Create an arr int[][] m = new int[row][col]; System.out.println("Enter a " + m.length + "x" for (int i = 0; i < m.length;="" i++)="" for="" (int="" j="0;" j="">< m[i].length; j++) 50 51 52 + m[0].length + " matrix and press enter: "); 53 54 55 m[i][j] = input.nextint(); 56 57 input.close(); 58 59 return m; 60 } 61 } m[i].length;="" j++)="" 50="" 51="" 52="" +="" m[0].length="" +="" "="" matrix="" and="" press="" enter:="" ");="" 53="" 54="" 55="" m[i][j]="input.nextInt();" 56="" 57="" input.close();="" 58="" 59="" return="" m;="" 60="" }="" 61="">
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here