Scriptlet Example : Data Type « JSP « Java






Scriptlet Example

<%--
  Copyright (c) 2002 by Phil Hanna
  All rights reserved.
  
  You may study, use, modify, and distribute this
  software for any purpose provided that this
  copyright notice appears in all copies.
  
  This software is provided without warranty
  either expressed or implied.
--%>
<%@ page import="java.text.*" session="false"%>
<html>
<head>
<title>Scriptlet Example</title>
</head>
<body>
<table border="0" cellpadding="3">
<tr>
   <th>Fahrenheit</th>
   <th>Celsius</th>
</tr>
<%
   NumberFormat fmt = new DecimalFormat("###.000");
   for (int f = 32; f <= 212; f += 20) {
      double c = ((f - 32) * 5) / 9.0;
      String cs = fmt.format(c);
%>
   <tr>
      <td align="RIGHT"><%= f %></td>
      <td align="RIGHT"><%= cs %></td>
   </tr>
<%
   }
%>
</table>
</body>
</html>


           
       








Related examples in the same category

1.double: Finding Average Grades
2.Casting to a New Type
3.An Automatic Data Conversion