»
AnglaisFran�aisVietnamien

Imprimer - Calculatrice de l'utilisation d'essence - JavaScriptBank.com

Version compl�te: jsB@nk » Calcul » Calculatrice de l'utilisation d'essence
URL: https://www.javascriptbank.com/gasoline-usage-calculator.html

Calculatrice de l'utilisation d'essence © JavaScriptBank.comEssayer de garder la trace des dépenses de l'essence? Cet JavaScript calcule le nombre de miles, vous obtenez par gallon - par jour et par an. Il calcule aussi le montant dépensé par an et combien de CO2 de votre voiture est en production.

Version compl�te: jsB@nk » Calcul » Calculatrice de l'utilisation d'essence
URL: https://www.javascriptbank.com/gasoline-usage-calculator.html



JavaScript
<script type="text/javascript"><!-- Begin/* This script and many more are available free online atCreated by: Matthew Ogden :: http://www.home.earthlink.net/~ogden1972/ */function d(){  var a = document.form1.miles.value;  var b = document.form1.gas.value;  var c = document.form1.days.value;  var cost = document.form1.cost.value;  mpg=a/b;  gpd=b/c;  mpg= Math.round(mpg*10)/10;  gpy=gpd*365;  co=gpy*19.36;  cpy=gpy*cost;  gpd= Math.round(gpd*1000)/1000;  gpy= Math.round(gpy*10)/10;  cpy= Math.round(cpy*100)/100;  co= Math.round(co);  document.form1.results.value="Your car is getting "+mpg+" miles per gallon. On the average you use "+gpd+" gallons per day. At that rate of consumption you will burn "+gpy+" gallons per year at a cost of $"+cpy+" per year. In addition, that produces "+co+" pounds of CO2 in one year.";}// End --></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="form1"><strong>Miles Traveled:</strong>  <input type="text" size="8" name="miles">   <strong>Gallons of Gas:</strong>  <input type="text" size="6" name="gas"><br><br><strong>Cost of Gas: $</strong><input type="text" size="4" name="cost">  <strong>Days Between Fill-Ups:</strong>  <input type="text" size="6" name="days"><br><br><input type="button" value="Calculate" onclick="d()"> <input type="Reset" value="Clear"><br><br><strong>Results</strong><br><textarea name="results" rows="5" cols="55" wrap style="border-width:0;overflow:hidden"onfocus="this.blur()"></textarea></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->