If- Else Ladder

A ladder means a vertical set of steps. It is a computer generated list of pairings used in eliminations.

If- Else Ladder

If- Else Ladder

        

A ladder means a vertical set of steps. It is a computer generated list of pairings used in eliminations.

In this example we are declaring a variable month of type String and initialize it with the value "January". We are using If- Else loop for the ladder. The loop will travel up to down and if the condition gets true then it will get out of the loop. We have defined the if- else condition inside the scriptlet. Scriptlet tag is used for the implementation of the business logic of the program.

 

The code of the program is given below:

 

 

<HTML>
  <HEAD>
    <TITLE>Using an if-else Ladder</TITLE>
  </HEAD>
  <BODY>
    <font bgcolor = "red" size = 10>
           Using an if-else Ladder</font>
    <%
        String month = "January";
        if(month == "January")
            out.println("It\'s January.");
        else if (month == "February")
            out.println("It\'s February.");
        else if (month == "March")
            out.println("It\'s March.");
        else if (month == "April")
            out.println("It\'s April.");
        else if (month == "May")
            out.println("It\'s May.");
        else if (month == "June")
            out.println("It\'s June.");
        else if (month == "July")
            out.println("It\'s July.");
		else if (month == "August")
            out.println("It\'s August.");
        else if (month == "September")
            out.println("It\'s September.");
        else if (month == "October")
            out.println("It\'s October.");
        else if (month == "November")
            out.println("It\'s November.");
        else if (month == "December")
            out.println("It\'s December.");
    %>
  </BODY>
</HTML>

The output of the program is given below:

Download this example.