import java.util.Arrays;
import java.util.Scanner;
public class Sorter
{
public static void main(String[] args)
{
int i = 0;
int j = 0;
boolean isDone = false;
Scanner scan = new Scanner(System.in);
System.out.println("How many numbers do you want to sort?");
int numberOfItems = scan.nextInt();
int[] list = new int[numberOfItems];
int numbersInput = numberOfItems;
while(numberOfItems > 0)
{
System.out.println("Enter a number.");
int aNumber = scan.nextInt();
list[i] = aNumber;
i++;
numberOfItems--;
}
Arrays.sort(list);
while(isDone != true)
{
if(j == (numbersInput))
{
isDone = true;
}
else
{
System.out.println(list[j]);
j++;
}
}
}
}
No comments:
Post a Comment