Page 303 - Computer science 868 Class 12
P. 303

49                  System.out.println ();
                   50              }

                   51          }
                   52      }

                 The output of the preceding program is as follows:
                 Enter the number of rows and columns : 3
                 3

                 Enter Nos. in Array : 1
                 Enter Nos. in Array : 2
                 Enter Nos. in Array : 3
                 Enter Nos. in Array : 4

                 Enter Nos. in Array : 5
                 Enter Nos. in Array : 6
                 Enter Nos. in Array : 7

                 Enter Nos. in Array : 8
                 Enter Nos. in Array : 9
                 1 2 3

                 4 5 6
                 7 8 9

                 1 4 7
                 2 5 8
                 3 6 9

                 3.  Using InputStreamReader
                 Here, InputStreamReader and BufferedReader are used to input values. Under “io” package, the above classes are
                 placed. Different methods are used such as Integer.parseInt(), Double.parseDouble(), etc are used.


                   Program 14    Accept numbers into a 3 × 3 array and then print the prime numbers present in it.

                   1       import java.io.*;

                   2       class prime
                   3       {

                   4           public static void main() throws IOException
                   5           {

                   6               InputStreamReader isr  =  new InputStreamReader(System.in);
                   7               BufferedReader br= new BufferedReader(isr);

                   8               int n[][] = new int[3][3];
                   9               int i,j,count=0,k;



                                                                                                                       301
                                                                                                              Arrays   301
   298   299   300   301   302   303   304   305   306   307   308