import java.util.Scanner;

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

	// while-loop pattern

	/*
		while (bool_expr) {
			// do this
		}		

		while the boolean expression is true,
		the block of code is repeatedly executed
	*/

	/*
		// infinite loop

		while(true) {
			System.out.println("help!!!");
		}
	*/
		
		int counter = 0;
		while (counter < 3) {
			System.out.println("counter: " + counter);
			counter = counter + 1;  // increment counter	
		}
	
		System.out.println("final value of counter: " + counter);	
		// print even numbers between 2 and 10

		counter = 2;
		while (counter <= 10) {
			System.out.println("counter: " + counter); 
			counter = counter + 2;
		}
	
		System.out.println("final value of counter: " + counter);

		int value = 1;
		value++;	//equivalent to value = value + 1
		value--;	//equivalent to value = value - 1 

		value += 2;	// same as value = value + 2;	
		value *= 2;	// same as value = value * 2;
		value -= 2;	// same as value = value - 2;
		value /= 2; 	// same as value = value / 2;

		// count backwards from -10 to -20 (inclusive)

		counter = -10;
		while(counter >= -20) {
			System.out.println("counter: " + counter);
			counter--;
		}

		System.out.println("final value of counter: " + counter);

		Scanner kb = new Scanner(System.in);

		char input = 'a';
		char secondToLastChar = 'a';

		while(input != 'e') {
			System.out.println("Enter a character (e to exit): ");
			secondToLastChar = input;
			input = kb.next().charAt(0);
		}
		System.out.println("second to last value of input: " + secondToLastChar);
		System.out.println("final value of input: " + input);


	
	}
}
