SmartCollegeVisit Fuel Calculator

Road_to_college


function fuelcalc() { var mpg = document.getElementById("mpg").value; var dist = document.getElementById("distance").value; var cost = document.getElementById("cost").value;

var result = ""; var error = "";

if (isNaN(parseInt(mpg.replace('.',''))) || isNaN(parseInt(dist.replace('.',''))) || isNaN(parseInt(cost.replace('.','')))) { result = ""; error = "An error occurred. All fields should be numbers." } else { result = "$" + parseFloat(cost)*parseFloat(dist)/parseFloat(mpg); if (result.indexOf(".",0) != -1) { result = result.substring(0,result.indexOf(".",0)+3); } error = ""; }

document.getElementById("result").value = result; document.getElementById("error").value = error; }

function reset() { document.getElementById("mpg").value = ""; document.getElementById("distance").value = ""; document.getElementById("cost").value = ""; document.getElementById("error").value = ""; document.getElementById("result").value = ""; }

//End //

Miles per gallon:
Distance (in miles):
Price per gallon: $

 

Get directions using Google Maps.

Check out our Travel Tips and College Visits Section for more great travel planning resources.



Subscribe To Our Newsletter

CampusChat keeps parents, students, educators and counselors informed of college news, tips, and resources -- all delivered directly to your inbox.

Your contact info will not be shared without your permission. We don't like spam and assume you don't either.

You have Successfully Subscribed!