O'Reilly logo

Java™ How To Program (Early Objects), Tenth Edition by Harvey Deitel, Paul Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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                                 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required