Finding Reciprocals : While « JSP « Java Tutorial






<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>








23.9.While
23.9.1.Using the while Loop
23.9.2.Finding a Factorial
23.9.3.Finding Reciprocals