public class Boxprize
{
    public static void main (String[] args)
    {
	int j;
	int boxes = 12, prize = 5; // Set number of boxes and prizes.
	int[] boxnum = new int [boxes]; // Make an array for each boxes
	boolean[] gotone = new boolean [prize]; // Make an array for each prize.
	boolean isall;
	long good = 0, bad = 0; // Set results to zero.
	int start = 1, finish = 1000000;

	for (int i = start ; i <= finish ; i++) // Loop begins from 'start' and increases by 1 until it is past 'finish'
	{
	    for (j = 0 ; j < boxes ; j++)
		boxnum [j] = (int) (Math.random () * 5); // Give each box a random number from 0 to 4.
	    for (j = 0 ; j < prize ; j++)
		gotone [j] = false; // Reset the prize array.
	    for (j = 0 ; j < boxes ; j++)
		gotone [boxnum [j]] = true; // Prize array element becomes true when its number is found in a box.
		
	    isall = true; // Prior to searching the prize array, assume it contains each prize.
	    for (j = 0 ; j < prize ; j++)
		if (!gotone [j]) // If a prize number has not been found,
		{
		    isall = false; // The sample does not contain all prizes.
		    bad++; // Increase the 'bad' number by 1.
		    break; // Stop searching the prize array as it is no longer necessary.
		}
	    if (isall) // If the prize array indeed contains each prize,
		good++; // Increase the 'good' number by 1.
	}
	// Outputting results below.
	long total = finish - start + 1;
	System.out.println (boxes + " boxes\n" + prize + " prizes\n" + total + " samples\n\n" + good + " contained all five prizes;\n" + bad + " did not.");

    }
}
