<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Cálculo de Consumo</title>
</head>
<body>
<script>
document.write("<h3>¿Alcohol o gasolina?</h3>");
var fuelTankCapacity = 40; // fuel tank capacity in liters
var maxTravelWGasoline = 480; //Maximum distance travelled with a full tank of gasoline
var maxTravelWAlcohol = 300; //Maximum distance travelled with a full tank of alcohol
var fuelEfficiencyGas = maxTravelWGasoline / fuelTankCapacity; //efficiency of gasoline
var fuelEfficiencyAlc = maxTravelWAlcohol / fuelTankCapacity; //efficiency of alcohol
document.write(
"La eficiencia de 40 litros de gasolina es: " +
Math.round(fuelEfficiencyGas) +
" km/lt"
);
document.write("<br>");
document.write(
"La eficiencia de 40 litros de alcohol es: " +
Math.round(fuelEfficiencyAlc) +
" km/lt"
);
</script>
</body>
</html>