Calculate your vehicle's Miles Per Gallon (MPG) easily.
Your MPG is:
Understanding Your Vehicle's MPG
Calculating your vehicle's Miles Per Gallon (MPG) is a straightforward process that helps you understand your fuel efficiency. This metric is crucial for monitoring your vehicle's performance, identifying potential mechanical issues, and managing your fuel budget effectively.
The Formula
The formula to calculate MPG is simple:
MPG = Total Distance Traveled / Total Fuel Used
In this calculator:
Distance Traveled: This is the total number of miles your vehicle has covered since the last time you tracked your fuel consumption.
Fuel Used: This is the total amount of fuel (in gallons) you added to your tank to cover that distance. It's best to fill your tank completely, record the odometer reading, drive until you need to refuel, fill the tank completely again, and then record the new odometer reading and the amount of fuel added.
How to Use This Calculator
Fill your gas tank completely.
Record your odometer reading or reset your trip odometer to zero.
Drive your vehicle normally until you need to refuel.
Fill your gas tank completely again.
Record the new odometer reading and calculate the distance traveled (New Odometer – Old Odometer).
Record the number of gallons you just added to fill the tank.
Enter the "Distance Traveled" (in miles) and "Fuel Used" (in gallons) into the calculator above.
Click "Calculate MPG" to see your vehicle's fuel efficiency.
Why Monitor Your MPG?
Cost Savings: Higher MPG means you spend less on fuel.
Vehicle Health: A sudden drop in MPG can indicate problems like underinflated tires, engine issues, or a dirty air filter.
Environmental Impact: Better fuel efficiency reduces your vehicle's carbon footprint.
Planning: Knowing your MPG helps in planning long trips and budgeting for fuel costs.
Example Calculation:
Let's say you fill up your car, reset your trip odometer, and drive 315 miles. When you stop for gas again, you fill up the tank with 10.5 gallons.
Using the formula: MPG = 315 miles / 10.5 gallons = 30 MPG
This means your car achieved 30 miles per gallon on that journey.
function calculateMPG() {
var distanceInput = document.getElementById("distanceTraveled");
var fuelInput = document.getElementById("fuelUsed");
var resultDiv = document.getElementById("result");
var mpgValueSpan = document.getElementById("mpgValue");
var distance = parseFloat(distanceInput.value);
var fuel = parseFloat(fuelInput.value);
if (isNaN(distance) || isNaN(fuel)) {
alert("Please enter valid numbers for both distance and fuel used.");
resultDiv.style.display = 'none';
return;
}
if (distance <= 0 || fuel <= 0) {
alert("Distance traveled and fuel used must be positive numbers.");
resultDiv.style.display = 'none';
return;
}
var mpg = distance / fuel;
mpgValueSpan.textContent = mpg.toFixed(2); // Display MPG with 2 decimal places
resultDiv.style.display = 'block';
}