Saturday, June 7, 2008

Gas Calculator Algorithms

Here are the algorithms I intend to use for the Gas Calculator. Keep in mind I'm Canadian so I'll be defaulting to liters, however I intend to build in the ability to use either liters or gallons. Also even though we use metric, the car dealerships still advertise Miles Per Gallon (MPG) efficiency so that's what I'll be using.

Input Options:
- Days Per Week (default 5)
- Distance from Home to Work
- Distance from Work to Home (in case someone takes a different route home)
- Miscellaneous distance traveled in a week (recreation, etc)
- Highway distance traveled in a month
- Vehicle MPG (highway mpg as well as city mpg)

Calculations:
- Gallons burned per month = (Total city travel / city MPG) + (Total highway travel / highway MPG)
- Gas cost per month = Liters burned per month * Cost per liter

Conversions:
- 1 mile = 1.6093 kilometers
- 1 kilometer = .06214 miles
- 1 US gallon = 3.7854 liters
- 1 liter = 0.2642 US gallons

I'm also gonna make a separate area/dialog box for unit conversion. Looks like VB Express 2008 is done installing so might as well start programming. :)

No comments: