Page 595 - ComputerScience_Class_11
P. 595

26                          break;

                   27                      }
                   28                  }

                   29                  if (!isSymmetric) break;

                   30              }

                   31              if (isSymmetric) {

                   32                  System.out.println("The matrix is symmetric.");
                   33              } else {

                   34                  System.out.println("The matrix is not symmetric.");

                   35              }

                   36          }

                   37          public static void main(String[] args) {

                   38              Scanner sc = new Scanner(System.in);

                   39              System.out.print("Enter the size of the square matrix (n): ");
                   40              if (sc.hasNextInt()) {

                   41                  int size = sc.nextInt();

                   42                  transposeSymmetric obj = new transposeSymmetric(size);

                   43                  obj.inputMatrix(sc);

                   44                  obj.transymcheck();
                   45              }

                   46          }

                   47      }


                 The output of the preceding program is as follows:

                       BlueJ: Terminal Window - Java
                   Options

                  Enter the size of the square matrix (n): 2
                  Enter the elements for a 2x2 matrix:
                  1
                  3
                  3
                  4
                  The matrix is symmetric.






                                                                                                Internal Assessment  593
   590   591   592   593   594   595   596   597   598   599   600