import java.util.InputMismatchException;
import java.util.Scanner;

public class IncreasingOrderArray {

    public static void main(String[] args)
    {
    	int SIZE =10;
    	int[] increasingArr = new int[SIZE];
    	int i=0;
        try (Scanner input = new Scanner(System.in)) {
			int number;
			char choice;
			do
			{
			    System.out.print("Enter a number (all numbers should be in increasing order): ");
			    number = input.nextInt();
			
			    if (i>0) 
			    {
				    if (increasingArr[i-1] < number)
				    {
				    	increasingArr[i] = number;
				        i++;
				    }
				    else 
				    {
				    	System.out.println("You must enter a number greater than the previous number("+ increasingArr[i-1]+")");
				    	System.out.println("There are still "+ (SIZE -i) + " numbers to be entered");
				    }
			    }
			    else { // first number is entered
			    	increasingArr[i] = number;
			        i++;
			    }
			    
		    	System.out.print("Do you want to continue y/n? ");
			    choice = input.next().charAt(0);
			    
			}while ((choice=='y' || choice == 'Y') && (i< SIZE));
		        

		System.out.println("There are currently "+ i + " numbers in the array");
		
		for (int k=0; k < i; k++)
		{
			System.out.print(increasingArr[k]+ " ");
		}
        }
    
    catch (InputMismatchException  e)
    {
    	System.out.println("Error reading input");
    }

}
}
