Nested if statements

// jamesprogram.java
class jamesprogram {

	public static void main(String args[]){
		
		int bananas=88;
		
		if (bananas<20){
			System.out.println("Not many bananas");
		}else{
			System.out.println("More than 20 bananas");
			
			if (bananas>80){
				System.out.println("More than 80 bananas");
			}else{
				System.out.println("Less than 80 bananas");
			}
		}
		
	}
}

This outputs:

More than 20 bananas
More than 80 bananas

Leave a Reply