ADVERTISEMENT
ADVERTISEMENT

Java program to find largest number among three numbers

Find largest number from three integer number in Java: This program will read three integer number from the keyboard and find the largest number.

Find largest among three numbers using Java Program

//Java program to find largest number among three numbers.
 
import java.util.*;
 
class LargestFrom3
{
    public static void main(String []s)
    {
        int a,b,c,largest;
        //Scanner class to read value
        Scanner sc=new Scanner(System.in);
         
        System.out.print("Enter first  number:");
        a=sc.nextInt();
        System.out.print("Enter second number:");
        b=sc.nextInt();
        System.out.print("Enter third  number:");
        c=sc.nextInt();
         
        if ( a>b && a>c )
            largest=a;
        else if ( b>a && b>c )
            largest=b;
        else
            largest=c;
         
        System.out.println("Largest Number is : "+largest);
         
    }
}

Output

    Complie 	:	javac LargestFrom3.java
    Run		:	java LargestFrom3
    Output
    Enter first  number:45
    Enter second number:56
    Enter third  number:67
    Largest Number is : 67

Java Basic Programs »


ADVERTISEMENT



ADVERTISEMENT



Comments and Discussions


ADVERTISEMENT

ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT

Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.