Java Program To Find Greatest Between Three Numbers

import java.util.Scanner;
class scan
{
public static void main(String arg[])
{
int x,y,z; 
Scanner kb=new Scanner(System.in);
System.out.println("Enter Three Numbers");
  System.out.print("x = ");
 x=kb.nextInt();
   System.out.print("y = ");
  y=kb.nextInt();
  System.out.print("z = ");
  z=kb.nextInt();
  if(x>y)
    {
	 if(x>z)
	  {
	   System.out.println(" x is Greater");
	  }
	  else
	  {
	  System.out.println(" z is Greater");
	  }
	  
	}
	else
	{
	if(y>z)
	 {
	 System.out.println(" y is Greater");
	 }
	 else
	 {
	 System.out.println(" z is Greater");
	 }
	}
}
}

OUTPUT:-

Enter Three Numbers
x = 45
y = 23
z = 12
x is Greater

Leave a Reply

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