Page 82 - Trackpad_ipro 4.1_Class8
P. 82

case 1:

                              System.out.println("Today is Monday");
                              break;
                          case 2:
                              System.out.println("Today is Tuesday");

                              break;
                          case 3:

                              System.out.println("Today is Wednesday");
                              break;
                          case 4:
                              System.out.println("Today is Thursday");

                              break;
                          case 5:
                              System.out.println("Today is Friday");

                              break;
                          case 6:
                              System.out.println("Today is Saturday");

                              break;
                          case 7:
                              System.out.println("Today is Sunday");

                              break;
                          default:
                              System.out.println("Invalid day number");
                          }

                      }
                  }
                  After compiling the preceding program, run it twice

                  and enter values 6 and 8. When you enter value 6, case
                  6 will be executed and the output “Today is Saturday”
                  will be displayed on the terminal.





                                                            When you enter  value 8, none of the cases will be
                                                            matched. Hence, the default case will be executed and

                                                            the output “Invalid day number” will be displayed on the
                                                            terminal.






                    80     iPro (Ver. 4.1)-VIII
   77   78   79   80   81   82   83   84   85   86   87