Answered step by step
Verified Expert Solution
Question
1 Approved Answer
6 7 Main.java 8 class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print(Enter dimensions: ); 9 10 11 12
6 7 Main.java 8 class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); System.out.print("Enter dimensions: "); 9 10 11 12 // 1. scan ints for the number of rows and cols 1/ declare a 2D array of ints with these dimensions 13 14 15 16 17 18 19 20 // 2. iterate over the 2D array and // use the Math.random() method (with other arithmetic // and casts) to assign a random integer value // between 0 and 10 (inclusive) into each index 21 // 3. use a for-each loop to iterate over the // 2D array and System.out each value // the output should look like a 2D array (grid) // 4. find the sum of all the values in the array 22 23 24 25 26 27 28 29 30 scan.close(); 31 32 33 } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started