viewing paste DisplayMatrix | Java

Posted on the
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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;
    }
    
}
Viewed 1328 times, submitted by Streusel.