Java Program to find Second Largest Number between Three | Java Programming | factsofanonymousbaba |


java program to find second largest number between there number
package secondlargestno;
//package name
import java.util.Scanner;
//import Scanner Class for getting input
public class Secondlargestno {
    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
//Creating Scanner class object s
           int a,b,c;
           System.out.println("Enter the three Numbers");
           a=s.nextInt();
           b=s.nextInt();
           c=s.nextInt();
//getting input from object
           if(a>b && a>c)
           {
               if(b>c)

               {
                        System.out.println("Second largest is:-"+b);
               }
               else
                {
                       System.out.println("Second largest is:-"+c);
                }
           }
           else if(b>a && b>c)
           {
               if(a>c)
               {
                   System.out.println("Second largest is:-"+a);
               }
               else
               {
                   System.out.println("Second largest is:-"+c);
               }
           }
           else if(c>a && c>b)
           {
               if(a>b)
               {
                   System.out.println("Second largest is:-"+a);
               }
               else
               {
                   System.out.println("Second largest is:-"+b);
               }
           }          
    }  
}
AnonymousBaba

"Facts of Anonymous Baba" are Providing you Best Interesting Facts, Technology Updates, Computer Knowledge, and Their Related Updates.

Post a Comment

Previous Post Next Post