Nested if...else Statements

A program can test multiple cases by placing if...else statements inside other if...else statements to create nested if...else statements. For example, the following pseudocode represents a nested if...else that prints A for exam grades greater than or equal to 90, B for grades 80 to 89, C for grades 70 to 79, D for grades 60 to 69 and F for all other grades:

If student's grade is greater than or equal to 90      Print "A"else     If student's grade is greater than or equal to 80           Print "B"     else           If student's grade is greater than or equal to 70                 Print "C"           else                 If student's grade is greater than or equal to 60                        ...

Get Android™ How to Program, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.