Page 125 - CA_Blue( J )_Class10
P. 125

else
                    {
                        if(Condition 3)
                            Statement 3;
                        else
                            Statement 4;
                    }
                                                                    Start



                                                               Input a, b and c




                                                     true                         false
                                                                   if(a>b)



                                  true                    false             true                    false
                                             if(a>c)                                    if(b>c)




                             print a                         print c    print b                        print c





                                                                                         End

                  Program 6    To input three numbers and print the greatest number.


                   1  import java.util.*;
                   2  class greatest_number
                   3  {

                   4      public static void main()
                   5      {

                   6          Scanner sc= new Scanner(System.in);
                   7          int a,b,c;

                   8          System.out.print("Enter first number :");
                   9          a=sc.nextInt();

                  10          System.out.print("Enter second number :");
                  11          b=sc.nextInt();

                  12          System.out.print("Enter third number :");
                  13          c=sc.nextInt();

                  14          System.out.println("--------------------------");





                                                                                                                       123
                                                                                           Conditional Constructs in Java  123
   120   121   122   123   124   125   126   127   128   129   130