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.

Kilometers per Liter to Miles per Gallon

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.