echo "

MPG Calculator

"; echo "

This relates to Imperial quantities - that is, this works for UK visitors.

"; echo "

If you use US Gallons, the calclations will be incorrect. If you would like this"; echo " feature to allow the option of US Gallons, please mail me and I will add that option. However, the "Pence Per Litre" option should work for all decimal (xx.xx) currencies."; "; if (isset($_POST["calc"])) { echo ""; echo ""; $g=$_POST["litres"] * 0.22; $mpg=$_POST["miles"] / $g; printf("", $g); printf("", $mpg); echo "
Litres" . $_POST["litres"] . "
Gallons%0.2f
MPG%0.2f
"; printf("

%0.2f miles fuelled by %0.2f litres equates to %0.2f MPG

", $_POST["miles"], $_POST["litres"], $mpg); $cost = $_POST["ppl"] * $_POST["litres"] / $_POST["miles"]; printf("

Cost per Mile at %0.2f pence per litre = %0.2f pence per mile

", $_POST["ppl"], $cost); } echo ""; echo ""; echo ""; echo ""; echo ""; echo "
LitresHow many Litres you put into the car
MilesHow many Miles the car drove
Pence Per LitreHow many pence you paid per litre at the pump
"; echo ""; echo "";