Page 214 - ComputerScience_Class_11
P. 214

10              b= sc.nextDouble();
                11              c= sc.nextDouble();

                12              System.out.println("--------------------------");
                13              if((a>b) && (a>c))
                14              {

                15                  if(b>c)

                16                      System.out.println(b + " is the 2nd greatest number");
                17                  else
                18                      System.out.println(c + " is the 2nd greatest number");

                19              }
                20              if((b>a) && (b>c))

                21              {
                22                  if(a > c)

                23                      System.out.println(a + " is the 2nd greatest number");
                24                  else

                25                      System.out.println(c + " is the 2nd greatest number");
                26              }

                27              if((c>a) && (c>b))
                28              {

                29                  if(a > b)
                30                      System.out.println(a + " is the 2nd greatest number");
                31                  else

                32                      System.out.println(b + " is the 2nd greatest number");

                33              }
                34              System.out.println("--------------------------");
                35          }

                36      }

              The output of the preceding program is as follows:
                     BlueJ: Terminal Window - Java
                 Options


                Enter three numbers : 6
                3
                5
                --------------------------
                5.0 is the 2nd greatest number
                --------------------------



                  212  Touchpad Computer Science (Ver. 3.0)-XI
   209   210   211   212   213   214   215   216   217   218   219