
Patrick B. answered 10/18/20
Math and computer tutor/teacher
import java.io.*;
class AscendingAndDescending
{
public void Go()
{
int A[] = new int[3];
String inbuff=null;
Console console = System.console();
//Input
System.out.print(" Please input the 1st # :>");
inbuff = console.readLine();
A[0] = Integer.parseInt(inbuff);
System.out.print(" Please input the 2nd # :>");
inbuff = console.readLine();
A[1] = Integer.parseInt(inbuff);
System.out.print(" Please input the 3rd # :>");
inbuff = console.readLine();
A[2] = Integer.parseInt(inbuff);
//Bubble Sorts the array
if ( A[0]>A[1])
{
int iTemp = A[1];
A[1]=A[0];
A[0] = iTemp;
}
if (A[1]>A[2])
{
int iTemp = A[2];
A[2] = A[1];
A[1] = iTemp;
}
if ( A[0]>A[1])
{
int iTemp = A[1];
A[1]=A[0];
A[0] = iTemp;
}
//Output
System.out.println(" Ascending... ");
for (int iLoop=0; iLoop<3; iLoop++) { System.out.println(A[iLoop]); }
System.out.println(" Descending... ");
for (int iLoop=2; iLoop>=0; iLoop--) { System.out.println(A[iLoop]); }
}
public static void main( String args[])
{
(new AscendingAndDescending ()).Go();
}
}