import java.text.*;     // Format, NumberFormat, DecimalFormat, ...
import java.io.*;     //  ..Reader , IOException, ... I/O related
public class p99  {
  /// main program should be static with String array argument
   public static void main( String p[ ])  throws IOException
   {  // main begins here
       int i,k, n;
       try{
           InputStreamReader isr = new InputStreamReader(System.in);
          BufferedReader br = new BufferedReader(isr);
          printf("print n x n table,  Give me n: ");
          n = Integer.parseInt( br.readLine( ) );
      } catch( Exception e) {
          printf("Exception occurs, choose 9 as default\n");
          java.awt.Toolkit.getDefaultToolkit( ).beep( );
          n=9;  // set default  9 x 9    
      }  // try ... catch ..
     /// ///
     printf("\n 9x9 | ");
     for(i=1; i<=n; ++i) { printn(i); printf(" "); }
     printf("\n");
     for(i=1; i<=n*5+6; ++i) printf("-"); printf("\n");
     for(i=1; i<=n; ++i) {
         printn(i); printf(" | ");
         for(k=1; k<=n; ++k) {
              printn( i*k ); printf(" ");
         }
         printf("\n");
     } // for i
     for(i=1; i<=n*5+6; ++i) printf("="); printf("\n");
  } // main
  static void printf(String s) {System.out.print(s); }
  static void printn(int n) {
       if(n<100) printf(" ");
       if(n<10) printf(" ");
       printf(" "+n);
  } // printn
}
/******************
C:\jtest\sample>javac p99.java
C:\jtest\sample>java p99
print n x n table,  Give me n: 8

 9x9 |    1    2    3    4    5    6    7    8
----------------------------------------------
   1 |    1    2    3    4    5    6    7    8
   2 |    2    4    6    8   10   12   14   16
   3 |    3    6    9   12   15   18   21   24
   4 |    4    8   12   16   20   24   28   32
   5 |    5   10   15   20   25   30   35   40
   6 |    6   12   18   24   30   36   42   48
   7 |    7   14   21   28   35   42   49   56
   8 |    8   16   24   32   40   48   56   64
==============================================

C:\jtest\sample>
*******************/
