Page 154 - computer science (868) class 11
P. 154

public static void main()
                      {
                          Scanner sc = new Scanner(System.in);
                          int ch1;
                          char ch2;
                          System.out.println("Enter number ch1 and character ch2");
                          ch1 = sc.nextInt();
                          ch2 = sc.next().charAt(0);
                          // Starting of Outer Switch
                          switch(ch1)
                          {
                              case 1:
                                  // Starting of Inner Switch
                                  switch ch2)
                                  {
                                      case 'B': System.out.println("The choice is B");
                                          break;
                                      case 'C':
                                          System.out.println("The choice is C");
                                          break;
                                      case 'D':
                                          System.out.println("The choice is D");
                                          break;
                                  }
                                  break;
                              case 2:
                                  System.out.println("The choice is 2");
                                  break;

                              case 3:
                                  System.out.println("The choice is 3");
                                  break;


                              default:
                                  System.out.println("Wrong choice");
                                  break;
                          }
                      }
                  }
              The output 1 of the preceding program is as follows:
              Enter number ch1 and character ch2
              1
              B
              The choice is B
              The output 2 of the preceding program is as follows:
              Enter number ch1 and character ch2
              2
              B
              Choice is 2


                152152  Touchpad Computer Science-XI
   149   150   151   152   153   154   155   156   157   158   159