Please help.. I have an assignment that states that we have to print out a matrix of random 0s and 1s, the size of n-by-n with n coming from user input. With that being said, I know I have to use Math.random() to get the 0s and 1s. My problem is trying to get the actual matrix because I've looked around and people say to use printf, but I've tried a lot of variations of that and I always end up with tons of errors or just several lines of decimals. I left a couple things out which I'll annotate with '???'.

Code Java:

//User inputs an integer and program displays matrix of random //0's and 1's import java.util.Scanner; public class Matrix { public static void main(String[] args) { Scanner input = new Scanner(System.in); //User inputs integer System.out.print("Please enter an integer: "); int n = input.nextInt(); printMatrix(n); } public static void printMatrix(int n) { while (n > 0) { System.out.println(" " + Math.random() * 2); n--; while (n > 0) { System.out.printf( ???, Math.random()); n--; } System.out.println(???); } } }