/**
 * Demonstrate inserting a value from the user into an array.
 *
 * @author	Terry Sergeant
 * @version Case Study v1.0
*/
import java.util.Scanner;

public class IntDemo2
{
	public static void main(String [] args)
	{
		Scanner kb= new Scanner(System.in);
		int i,n;
		int [] numbers= new int[50];

		n= 7;
		for (i=0; i<n; i++)
			numbers[i]= (int) (Math.random()*18.0);

		displayNumbers(numbers,n);

		System.out.print("Enter another number to be added to the array: ");
		numbers[n]= kb.nextInt();
		n++;

		displayNumbers(numbers,n);
	}


	/**
	 * Displays the first n numbers in the provided array.
	 * 
	 * @param numbers an array of integers to be displayed
	 * @param n the number of values to be displayed
	*/
	public static void displayNumbers(int [] numbers, int n)
	{
		int i;

		System.out.println("Array has "+n+" values. Here they are: ");
		for (i=0; i<n; i++)
			System.out.println(numbers[i]);
	}
}
