Java Program to Find Largest Number out of 3 Numbers

In this program we will write a Java program to find Largest of Three Numbers. We will be using the If-Else conditional control statements to check if the number entered is Even or Odd.

Java Largest of Three Numbers Program Code Example –
import java.util.Scanner;
 
class LargestOfThreeNumbers
{
   public static void main(String args[])
   {
      int x, y, z;
      System.out.println("Enter three integers ");
      Scanner in = new Scanner(System.in);
 
      x = in.nextInt();
      y = in.nextInt();
      z = in.nextInt();
 
      if ( x > y && x > z )
         System.out.println("First number is largest.");
      else if ( y > x && y > z )
         System.out.println("Second number is largest.");
      else if ( z > x && z > y )
         System.out.println("Third number is largest.");
      else   
         System.out.println("Entered numbers are not distinct.");
   }
}
Output
10 9 4
First number is largest.
Watch it on YouTube

Leave a Reply

Your email address will not be published. Required fields are marked *