Prints a conversion table of miles per gallon to kilometers per liter
<%-- 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 session="false" %> <%@ page import="java.io.*" %> <%@ page import="java.text.*" %> <%@ page import="java.util.*" %> <%-- Prints a conversion table of miles per gallon to kilometers per liter --%> <%! private static final DecimalFormat FMT = new DecimalFormat("#0.00"); private static final double CONVERSION_FACTOR = 2.352145; %> <html> <head> <title>Fuel Efficiency Conversion Chart</title> </head> <body> <center> <h1>Fuel Efficiency Conversion Chart</h1> <table border='1' cellpadding='3' cellspacing='0'> <tr> <th>Kilometers per Liter</th> <th>Miles per Gallon</th> </tr> <% for (double kmpl = 5; kmpl <= 20; kmpl += 1.0) { double mpg = kmpl * CONVERSION_FACTOR; %> <tr> <td align='right'><%= FMT.format(kmpl) %></td> <td align='right'><%= FMT.format(mpg) %></td> </tr> <% } %> </table> </center> </body> </html>
1. | JSP HTML Table | ![]() | |
2. | Output Simple HTML Tag Jsp | ![]() | |
3. | Output HTML | ||
4. | Celsius Fahrenheit Table Jsp | ![]() | |
5. | Print ASCII Table Jsp | ![]() |