/*
 * looops
 * 
 *  
 * break, continue
 */

import java.util.Scanner;

class Sep14 {
	public static void main(String[] args) {

		// Ask the user to enter in a sequence of integers ending in 0.
		// Count how many non-zero integers they entered

		Scanner kb = new Scanner(System.in);

		System.out.println("Please enter a sequence of integers ending in 0");

		int input = kb.nextInt();
		int counter = 0;

		while(input != 0) {
			counter++;
			input = kb.nextInt();	
		}
		
		System.out.println("counter: " + counter);

		// Ask the user to enter in a sequence of integers ending in 0.
		// Print the smallest non-zero input that they've entered

		System.out.println("Please enter a sequence of integers ending in 0");
		int min = Integer.MAX_VALUE;
		input = kb.nextInt();
		
		while(input != 0) {
			
			// if the value in input is smaller than the value in min
			// change min to the value in input

			if(input < min) {
				min = input;
			}
			
			input = kb.nextInt();
		}
		System.out.println("min: " + min);

		// an infinite loop
		/*
		while(true) {
			System.out.println("x");

		}
		*/

		// The break keyword breaks execution out of the innermost loop

		System.out.println("Please enter a sequence of integers ending in 0");
		input = kb.nextInt();

		while(true) {
			if (input == 0) {
				break;
			}
			System.out.println("thank you");
			input = kb.nextInt();
		}

		System.out.println("whew");       
		
		// The continue keyword continues execution at the top of the
		// loop (re-evaluating the loop's boolean expression)

		System.out.println("Please enter a sequence of integers ending in 0");
		input = kb.nextInt();

		while(true) {
			if (input == 5) {
				input = kb.nextInt();
				continue;
			}

			if (input == 0) {
				break;
			}
			System.out.println("thank you");
			input = kb.nextInt();
		}

		System.out.println("whew");       
	}
}
