Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Jsp Simple-jsp-example Kilometers per Liter to Miles per Gallon

Related Tutorials


 
 

Share on Google+Share on Google+

Kilometers per Liter to Miles per Gallon

Advertisement
Kilometers per liter : The distance traveled by a vehicle which is running on gasoline or diesel fuel in a kilometer.

Kilometers per Liter to Miles per Gallon

        

Kilometers per liter : The distance traveled by a vehicle which is running on gasoline or diesel fuel in a kilometer. 

Miles per Gallon: The distance traveled by a vehicle which is running on gasoline or diesel fuel in a mile.

Suppose we need to convert the kilometers per liter into miles per gallon then there is one formula by which we can convert the kmpl to mpg that is mpg = kmpl * Conversion_factor. The value of the conversion factor is 2.352145 which is constant.

 

The code of the program is given below:

 

<html>
<head>
<title>ConversionTable of Kilometers perLiter and Miles per Gallon </title>
</head>
<body>
<FONT SIZE="6" COLOR="#CC99FF">ConversionTable of Kilometers
perLiter and Miles per Gallon</FONT>
<table border="1" bgcolor="#CCCCFF">
<tr><td><b>Kilometers per Liter</b></td><td><b>Miles per Gallon</b></td><tr>
<%
double kmpl=0.0;
double mpg=0.0;
final double CONVERSION_FACTOR = 2.352145;
>for ( kmpl = 5; kmpl < 25;kmpl++){
		mpg = kmpl * CONVERSION_FACTOR;
	%>	
<tr>
<td><%=kmpl%>
</td>
<td><%=mpg%>
</td>
</tr>
<%    
}
%>
</table>
</body>
</html>

Output of the Program:

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: March 12, 2008

Related Tutorials

Discuss: Kilometers per Liter to Miles per Gallon  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:0
DMCA.com