(Solved):JAVA not C++ Write a method that displays an n-by-n matrix using the following header: public static void printMatrix(int n) Each element is 0 through 9, which is generated randomly. Write a test p… View Answer…

 

Question

Write a JAVA method that displays an n-by-n matrix using the following header:

public static void printMatrix(int n)

Each element is 0 through 9, which is generated randomly.

Write a test program that prompts the user to enter n and displays an n-by-n matrix.

Here is a sample run: Enter n: 4

0 3 4 2

5 4 8 2

3 3 7 6

2 1 4 9

 

EXPERT ANSWER

import java.util.Scanner;
public class Matrix {
 
public static

Scroll to top