Question: GridPractice.java coding: import java.util.Scanner; import java.util.Random; public class GridPractice { public static void main(String[] args) { //declarations Scanner in = new Scanner(System.in); Random generator =

![static void main(String[] args) { //declarations Scanner in = new Scanner(System.in); Random](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66d9b391114ab_31266d9b390ab524.jpg)
![generator = new Random(); int [][] grid; //un-instantiated grid int size =](https://s3.amazonaws.com/si.experts.images/answers/2024/09/66d9b391add8b_31366d9b3914b3bf.jpg)
GridPractice.java coding:
import java.util.Scanner;
import java.util.Random;
public class GridPractice {
public static void main(String[] args) {
//declarations
Scanner in = new Scanner(System.in);
Random generator = new Random();
int [][] grid; //un-instantiated grid
int size = 0; /umber of rows and columns
//get size of grid - no validation & instantiate
System.out.print("Enter size of grid: ");
size = in.nextInt();
grid = new int[size][size];
//fill grid with random number from 1..99
System.out.println();
for (int row=0; row for (int col=0; col grid[row][col] = generator.nextInt(100); //random numbers 0.99 - not 100
}
}
//STEP 3(exercise 1): print grid with formatting to align
//STEP 4A (exercise 2): print each row sum
//STEP 4B (exercise 2): print each column sum
//STEP 5 (exercise 3): print two diagonal sums
}
}
Lab 10: 2-Dimensional Arrays Note: All Exercises must be completed during the lab period. Exercise 1- Grid sums (5 points) 1. Download the file GridPractice.zip from myCourses that unzips to a file named GridPractice.java. There are no other classes as all code will be in the main method. After the user enters a size, the program creates a 2-dimensional array (named grid) with the size to specify the number of rows and columns. To avoid typing a great deal of input, the program stores random numbers between 0.. 99 into each position in grid. 2. . Write the code to print the contents of the gridas shown in the Sample Output. To have the columns align, you will need to use the printf command. When the program works correctly, have the instructor or TA check the code and initialize. Have instructor or TA sign here when Exercise 1 works correctly. Exercise 2- Row and Column Sums (3 points) 4 Write the code to calculate and print the sum of each row and each column. (See Example). Have instructor or TA sign here when Exercise 2 works correctly. Exercise 3- Diagonal Sums (2 points) Write the code to calculate and print the sum of the two diagonals. Assume that the size is 3. One diagonal starts in the upper left corner [0] [0])and ends in the lower right corner ( [2] [2]). The other diagonal starts in the upper right corner ([0] [2]) and end in the lower left corner ([2] [0]) 5. Have instructor or TA sign here when Exercise 3 works correctly