Page 228 - CA_Blue( J )_Class9
P. 228

16                  i=i/10;
                    17              }

                    18              if(s == p)
                    19                  System.out.println(n+ " is Spy number.");

                    20              else
                    21                  System.out.println(n+" is not spy number.");
                    22          }

                    23      }

                  You will get the following output:




















                                  Write a menu-driven program to print the following series:
                    Program 18
                                  i.  0 3 8 15 …… 99
                                        2
                                  ii.  s= +  4  +  6  +  .... + 10
                                              8
                                                     12
                                        4
                                           6
                     1      import java.util.*;
                     2      class prog_series_switchcase
                     3      {
                     4          public static void main ()

                     5          {

                     6              Scanner sc = new Scanner (System.in);
                     7              int i, ch;
                     8              System.out.println("Enter 1 for Series 1 and 2 for Series_2");

                     9              ch=sc.nextInt();
                    10              switch(ch)

                    11              {
                    12                  case 1:   for(i=1;i<=10; i++)

                    13                  {   System.out.print((i*i-1)+ " "); }






                   226    Touchpad Computer Applications-IX
   223   224   225   226   227   228   229   230   231   232   233