0% found this document useful (0 votes)
6 views2 pages

Sort Three Integers in Java

The Java program prompts the user to input three integers and determines their order by identifying the highest, second, and third values. It uses conditional statements to compare the integers and print the results accordingly. The program ensures that the highest number is displayed first, followed by the second and third highest numbers.

Uploaded by

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

Sort Three Integers in Java

The Java program prompts the user to input three integers and determines their order by identifying the highest, second, and third values. It uses conditional statements to compare the integers and print the results accordingly. The program ensures that the highest number is displayed first, followed by the second and third highest numbers.

Uploaded by

ackermanlayla4
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

import [Link].

JOptionPane;
public class AscendingAndDescending
{
public static void main(String[] args)
{
int one =
[Link]([Link](null,"Enter 3
integers "));
int two =
[Link]([Link](null,"Enter 3
integers "));
int three =
[Link]([Link](null,"Enter 3
integers "));

if(one > two && one > three)


{
[Link]("Highest: "+ one);
if(two > three){
[Link]("Second: "+ two);
[Link]("Third: "+ three);
}else if(two < three){
[Link]("Second: "+ three);
[Link]("Third: "+ two);
}

}else if(two > one && two > three)


{
[Link]("Highest: "+two);
if(three > one)
{
[Link]("Second: "+ three);
[Link]("Third: "+one);
}else if(three < one)
{
[Link]("Second: "+ one);
[Link]("Third: "+three);
}
}else if(three > one && three > two)
{
[Link]("Highest: "+three);
if(two > one)
{
[Link]("Second: "+two);
[Link]("Third: "+ one);
}else if(two < one)
{
[Link]("Second: "+one);
[Link]("Third: "+ two);
}

You might also like