Testing for Multiple Conditions : Statements « JSP « Java






Testing for Multiple Conditions

<HTML>
  <HEAD>
    <TITLE>Testing for Multiple Conditions</TITLE>
  </HEAD>

  <BODY>
    <H1>Testing for Multiple Conditions</H1>
    <%
        int temperature = 64;

        switch(temperature) {
            case 60:
            case 61:
            case 62:
                out.println("Sorry, too cold!");
                break;
            case 63:
            case 64:
            case 65:
                out.println("Pretty cool.");
                break;
            case 66:
            case 67:
                out.println("Nice!");
                break;
            case 70:
            case 74:
            case 75:
                out.println("Fairly warm.");
                break;
            default:
                out.println("Too hot!");
        }
    %>
  </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.Using the switch Statement
9.Using an if-else Ladder
10.Nested if Statements
11.Using Compound Statements