While statement : Statements « JSP « Java






While statement

<HTML>
  <HEAD>
    <TITLE>Finding Reciprocals</TITLE>
  </HEAD>

  <BODY>
    <H1>Finding Reciprocals</H1>
    <%
        double values[] = {4, 3, 2, 1, 0, 1, 2, 3, 4};
        int i = 0;

        while (values[i] != 0){
            out.println("The reciprocal = " + 1 / values[i++] + ".<BR>");
        } 
    %>
  </BODY>
</HTML>


           
       








Related examples in the same category

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