KEMBAR78
Nested IF | PDF
0% found this document useful (0 votes)
12 views3 pages

Nested IF

The document contains a Java program that determines the greatest of five numbers: a, b, c, d, and e. It uses nested if statements to compare the values and print which number is the greatest or if one of the other values is greater. The program initializes the variables with specific values and evaluates them through a series of conditional checks.

Uploaded by

BlazeSpace YT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views3 pages

Nested IF

The document contains a Java program that determines the greatest of five numbers: a, b, c, d, and e. It uses nested if statements to compare the values and print which number is the greatest or if one of the other values is greater. The program initializes the variables with specific values and evaluates them through a series of conditional checks.

Uploaded by

BlazeSpace YT
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Greatest in 5 Numbers

public class NestidIfWith5Numbers


{

public static void main(String[] args)


{

int a,b,c,d,e;
a=-13500+489;
b=1;
c=-1;
d=-2;
e=2;

if (a>b)
{
if (a>c)
{
if (a>d)
{
if (a>e)
{
System.out.println("A is Greater");
}
else
{
System.out.println("E1 is Greater");
}
}
}
else
{
if (c>d)
{
if (c>e)
{
System.out.println("C is Greater");
}
else
{
System.out.println("E3 is Greater");
}
}
else
{
if (d>e)
{
System.out.println("D is Greater");
}
else
{
System.out.println("E4 is Greater");
}
}
}
}
else
{
if (b>c)
{
if (b>d)
{
if (b>e)
{
System.out.println("B is Greater");
}
else
{
System.out.println("E5 is Greater");
}
}
else
{
if (d>e)
{
System.out.println("D2 is Greater");
}
else
{
System.out.println("E6 is Greater");
}
}

}
else
{
if (c>d)
{
if (c>e)
{
System.out.println("C2 is Greater");
}
else
{
System.out.println("E7 is Greater");
}
}
else
{
if (d>e)
{
System.out.println("D3 is Greater");
}
else
{
System.out.println("E8 is Greater");
}
}
}
}
}
}

You might also like