Created
September 3, 2015 15:22
-
-
Save heavymetta/817657f9c544566591ab to your computer and use it in GitHub Desktop.
State & City
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
states = { | |
OR: 'Oregon', | |
FL: 'Florida', | |
TX: 'Texas', | |
NY: 'New York' | |
} | |
# task1 ///// | |
states[:OG] = 'Oregon' | |
states[:COLO] = 'Colorado' | |
# task2 ///// | |
@cities = { | |
OR: 'Portland', | |
FL: 'Tampa', | |
TX: 'Dallas', | |
NY: 'New York' | |
} | |
#task3 ///// | |
def describe_state(state) | |
@cities[state] | |
end | |
puts describe_state(:NY) | |
#task 4 ///// | |
@taxes = {OG: 9, COLO: 8} | |
#task 5 ///// | |
def calculate_tax(price_of_item, state) | |
tax = @taxes[state] / 100.to_f | |
tax_paid = price_of_item * tax | |
tax_paid.round(2) | |
end | |
puts calculate_tax(50, :OG) | |
puts calculate_tax(60, :COLO) | |
#task 6 ///// | |
def find_state_for_city(seeking_city) | |
@cities.keys.each do |state| | |
if @cities[state] == seeking_city | |
puts "#{seeking_city} is located in #{state} state" | |
end | |
end | |
end | |
find_state_for_city('Portland') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment