Question: Write a full java program that prompts the user for an integer n and then creates a two-dimensional array of type int of size nn.
Write a full java program that prompts the user for an integer n and then creates a two-dimensional array of type int of size nn. It should fill the array with random values between 0 and 20 using Random class or the Math.random method within a nested loop. Then, compute the sum of all elements in the diagonal of the array. Finally, display both the array and the sum of the elements of the diagonal.
Enter integer: 5 The array created is: 0154127169181526031731317019255613 The sum of the diagonal elements is: 22
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
