Skip to content

Instantly share code, notes, and snippets.

@denniskeefe
Last active December 19, 2015 06:58
Show Gist options
  • Save denniskeefe/5914791 to your computer and use it in GitHub Desktop.
Save denniskeefe/5914791 to your computer and use it in GitHub Desktop.
avg_fuel_economy = 22
avg_fuel_price = 3.60
avg_fuel_price.to_f
#make sure we're calculating float and float in cost below
print "How many miles will you travel?"
distance = gets.chomp
puts "Distance as input: #{distance}"
distance = distance.to_f
puts "Distance as float: #{distance}"
cost = (distance * avg_fuel_price) / avg_fuel_economy
puts "Cost: #{cost}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment