Create a program that will allow the user to enter ten numbers and sort the numbers in an ascending and descending order.
import java.io.*;
import java.util.Arrays;
public class Oc13
{
public static void main (String args[]) throws IOException
{
DataInputStream whatever = new DataInputStream (System.in);
int earth[] = new int [10];
int temp;
System.out.println("Enter 10 numbers: ");
for (int i = 0; i< earth.length/2; ++i )
{ temp = earth[i];
earth[i] = earth[earth.length - i - 1];
earth[earth.length - i - 1] = temp; }
System.out.println("Descending Order: " + Arrays.toString(earth));
} }
No comments:
Post a Comment