To find the largest of three numbers

PROGRAM :

import java.util.Scanner;
public class Largest {
         public static void main(String[] args) {
     
        System.out.println("enter the first number");
        Scanner s = new Scanner(System.in);
        int a,b,c;
        a= s.nextInt();
        System.out.println("enter the second number");
        b= s,nextInt();
        System.out.println("enter the third number");
        c= s.nextInt();
        if (a> b)
          {
                  if (b>c)
                         {   System.out.println("largest number is :"+a);
                          }
          }
           if (b> c)
          {
                  if (c>a)
                         {   System.out.println("largest number is :"+b);
                          }
          }
          if (c> b)
          {
                  if (b>a)
                         {   System.out.println("largest number is :"+c);
                          }
          }
      else
          System.out.println("all numbers are   equal);
}
}

No comments:

Post a Comment