import javax.swing.JOptionPane; public class DisplayMatrix{ public static void main(String[] args){ String inputnumber = JOptionPane.showInputDialog(null, "Please input a number", "CPSC 1150 Lab 7", JOptionPane.QUESTION_MESSAGE); int number = Integer.parseInt(inputnumber); printMatrix(number); } public static void printMatrix(int n){ int i,j; String message = new String(); for(i = 1; i <= n; i++){ for(j = 1; j <= n; j++){ message += ((0 + (int)(Math.random() * 2))+" "); } message += "\n"; } JOptionPane.showMessageDialog(null, message); return; } }