class IfStatement {
	/*
	 * If statements allow execution of a block
	 * of code depending on whether a condition is true or false
	 * In general an if-statement looks like
	 *
	 * if(condition){
	 * 	block
	 * }
	 *
	 * where condition evaluates to a boolean (true/false)
	 * and block is a block of java statements.
	 * 
	 * This code is executed as follows: condition is evaluated,
	 * if condition is true, then block is executed, otherwise
	 * block is skipped
	 * 
	 * another form of the if-statement is the following
	 * 
	 * if(condition){
	 * 	block1
	 * } else {
	 * 	block2
	 * }
	 * 
	 * In this case, block1 is executed if condition evaluates to true
	 * otherwise, block2 is executed. In any case, exactly 1 of block1
	 * and block2 are executed.
	 * 
	 * You can 'chain' if-statements as follows:
	 * 
	 * if(condition1){
	 * 	block1
	 * } else if(condition2) 
	 * 	block2
	 * }
	 * 
	 * In this case, block1 is executed if condition1 is true,
	 * otherwise, the second if statement is executed, that is
	 * condition2 is checked, if it evaluates to true, then block2
	 * is executed.
	 * 
	 * Note: Java allows you to omit the { and } around the block
	 * when block consists of a single statement.
	 * 
	 * Note: any of the blocks themselves can be if-statements
	 */

	public static void main(String [] args){
		int i;
		i=1;
		System.out.println("i="+i);
		if(i==2 || i==3){
			System.out.println("i is 2 or 3"); 
		}

		if(i>10 && i<20)System.out.println("i is between 10 and 20"); 
		// Above is allowed since the block is a single statement

		i=i+1;
		System.out.println("i="+i);
		if(i==2 || i==3)System.out.println("i is 2 or 3");
		if(i>7){ 
			System.out.println("i is larger than 7"); 
		} else { 
			System.out.println("i is at most 7"); 
		}
		i=i+9;
		System.out.println("Now i="+i);
		if(i>7){ 
			System.out.println("i is larger than 7"); 
			if(i<=20)System.out.println("i is also at most 20");
		} else { 
			System.out.println("i is at most 7"); 
		}
	}
}
