Home Jsp Simple-jsp-example Nested If Statements



Nested If Statements
Posted on: February 7, 2008 at 12:00 AM
We use the if condition to check if the particular condition is true then it should perform a certain task, and if a particular condition is not true then it should do some other tasks.

Nested If Statements

        

We use the if condition to check if the particular condition is true then it should perform a certain task, and if a particular condition is not true then it should do some other tasks. Consider a situation where we have to use multiple if conditions then there we have to use nested if statements.

 

Code of the program is given below:

 

 

<HTML>
  <HEAD>
    <TITLE>Nested if Statements</TITLE>
  </HEAD>
  <BODY>
    <H1>Nested if Statements</H1>
    <%
        double value = 5;
        if (value != 0) {
            if (value > 0)
               out.println("The result = " + (1 + value));
            else
               out.println("The result = " + (1 - value));
        }
    %>
  </BODY>
</HTML>

The output of the program is given below:

Download this example.

Related Tags for Nested If Statements:
cideiomultiplenestedipstateidifconditionwherestatementtoeitmultiuseulstaconditionsmntsidsideesemmestatementsuatstipathastatconsssthcondavstatiiplpleplndono


More Tutorials from this section

Ask Questions?    Discuss: Nested If Statements  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.