Following Program will find the Greatest Number Out of Five Numbers and Consider Equality also:
Code:
public class NT {
public static void main(String[] nt)
{
int a=76,b=23,c=75,d=67,e=76;
if(a>b)
{
if(a>c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A is Greatest");
}
else if(a==e)
{
System.out.println("A,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,D are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else if(a==c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A,C are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,C,D are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("e is greatest");
}
}
}
else
{
if(c>d)
{
if(c>e)
{
System.out.println("C is Greatest");
}
else if(c==e)
{
System.out.println("C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(c==d)
{
if(c>e)
{
System.out.println("C,D are Greatest and Equal");
}
else if(c==e)
{
System.out.println("C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E is Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
}
else if(a==b)
{
if(a>c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A,B are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,E is Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,B,D is Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else if(a==c)
{
if(a>d)
{
if(a>e)
{
System.out.println("A,B,C are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(a==d)
{
if(a>e)
{
System.out.println("A,B,C,D are Greatest and Equal");
}
else if(a==e)
{
System.out.println("A,B,C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else
{
if(c>d)
{
if(c>e)
{
System.out.println("C is Greatest");
}
else if(c==e)
{
System.out.println("C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(c==d)
{
if(c>e)
{
System.out.println("C,D are Greatest and Equal");
}
else if(c==e)
{
System.out.println("C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
}
else
{
if(b>c)
{
if(b>d)
{
if(b>e)
{
System.out.println("B is Greatest");
}
else if(b==e)
{
System.out.println("B,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(b==d)
{
if(b>e)
{
System.out.println("B,D are Greatest and Equal");
}
else if(b==e)
{
System.out.println("B,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else if(b==c)
{
if(b>d)
{
if(b>e)
{
System.out.println("B,C are Greatest and Equal");
}
else if(b==e)
{
System.out.println("B,C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(b==d)
{
if(b>e)
{
System.out.println("B,C,D are Greatest and Equal");
}
else if(b==e)
{
System.out.println("B,C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
else
{
if(c>d)
{
if(c>e)
{
System.out.println("C is Greatest");
}
else if(c==e)
{
System.out.println("C,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else if(c==d)
{
if(c>e)
{
System.out.println("C,D is Greatest and Equal");
}
else if(c==e)
{
System.out.println("C,D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
else
{
if(d>e)
{
System.out.println("D is Greatest ");
}
else if(d==e)
{
System.out.println("D,E are Greatest and Equal");
}
else
{
System.out.println("E is Greatest");
}
}
}
}
}
}
Output: