Nested if Statements : Statements « JSP « Java






Nested if Statements

<HTML>
  <HEAD>
    <TITLE>Nested if Statements</TITLE>
  </HEAD>

  <BODY>
    <H1>Nested if Statements</H1>
    <%
        double value = 2;

        if (value != 0) {
            if (value > 0)
               out.println("The result = " + (1 / value));
            else
               out.println("Sorry, we need a positive number.");
        }
    %>
  </BODY>
</HTML>

           
       








Related examples in the same category

1.Using the continue Statement
2.Using the break Statement
3.While statement
4.While: Finding a Factorial
5.Using the while Loop
6.For loop: Using Two Loop Indexes
7.Using the if Statement
8.Testing for Multiple Conditions
9.Using the switch Statement
10.Using an if-else Ladder
11.Using Compound Statements