Skip to content

Instantly share code, notes, and snippets.

@jilucev
Last active August 29, 2015 13:57
Show Gist options
  • Save jilucev/9381660 to your computer and use it in GitHub Desktop.
Save jilucev/9381660 to your computer and use it in GitHub Desktop.
Here is a less messed up code w1d3
states = {
OR: 'Oregon',
FL: 'Florida',
CA: 'California',
NY: 'New York',
MI: 'Michigan'
}
states[:AR] = "Arkansas"
states[:HA] = "Hawaii"
cities = {
OR: ["Portland", "Eugene"],
FL: ["Alford", "Baldwin"],
CA: ["SanFrancisco", "Los Angeles"],
NY: ["Manhattan", "Abalone"],
MI: ["Detroit", "Kalamazoo"],
AR: ["Conway", "Rogers"],
HA: ["Maui", "Honolulu"],
}
taxes = {
OR: 7.5,
FL: 80,
CA: 3.6,
NY: 5.5,
MI: 9,
AR: 15,
HA: 4,
}
def describe_state(states, cities)
puts "What state or province do you want to know about?"
answer = gets.chomp.to_sym.upcase
state = states[answer]
city = cities[answer]
puts city.size
puts city
puts state
end
def calculate_tax(location, total_purchase)
tax_amount = taxes[location] * total_purchase
return tax_amount/100
end
def find_state_for_city(city)
puts (cities.index(city))
end
describe_state(states,cities)
calculate_taxes(CA, 123.49)
find_state_for_city(Portland)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment