
import java.util.Scanner;

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

		int i = 0;
		while(i <= 20) {
			// do something
			System.out.print(i + " ");
			
			i++;
		}
		System.out.println();

		// equivalent code with for-loop

		for(int j = 0; j <= 20; j++) {
			System.out.print(j + " ");
		}
		System.out.println();
		
		// compute sum of integers using for-loop

		int sum = 0;
		for(int j = 0; j <= 20; j++) {
			sum = sum + j;
		}
		System.out.printf("Sum: %d\n", sum); 	


		/* infinite for-loop

		for(;;) {
			System.out.println("help");
		}
		*/


		/* Use for-loop for menu

		Scanner kb = new Scanner(System.in);

		int option = 0;	
		for(; option != 3;) {
			System.out.println("1: add\n2: sub\n3: exit\n");
			System.out.print("Enter option: ");
			option = kb.nextInt();
		}
		
		// The scope of a variable is the block in which it
		// is defined.
		
		System.out.println("option: " + option);

		//print even numbers between lower and upper bound

		System.out.print("Enter lower and upper bound: ");
		int lower = kb.nextInt();
		int upper = kb.nextInt();

		for(int j = lower; j <= upper; j++) {
			if(j % 2 == 0) {
				System.out.printf("%d ", j);
			}
		}
		System.out.println();



	}
}
