Write a Java Program to find Largest among three Numbers

By | 20.01.2017

Write a Java Program to find Largest among three Numbers


Input three number from user and compare these number with each others and find largest number among these three numbers.

SOURCE CODE ::

import java.util.Scanner;
public class Largest 
{

    public static void main(String[] args) 
    {

        int a,b,c,largest;
        Scanner sc=new Scanner(System.in);
        System.out.println("Enter three numbers: ");
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();

            if(a>=b && a>=c) 
            {
                System.out.println("Largest number = "+a);
            }
            if(b>=a && b>=c) 
            {
                System.out.println("Largest number = "+b);
            }
            if(c>=a && c>=b) 
            {
                System.out.println("Largest number = "+c);
            }
    }
 }

 

OUTPUT ::

 

Enter three numbers: 
23
33
14
Largest number = 33

 

4.3 3 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
hion

Khaled Ibn Sultan
Ibn Fake7 El Marshdah
Besbous ashig bessa
we dallaha besbousa