Created
June 2, 2009 08:18
-
-
Save Lara-zz/122141 to your computer and use it in GitHub Desktop.
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
when 3 | |
print "Enter the name of the product you want to delete: " | |
$stdout.flush | |
name = gets.chomp.upcase | |
findkey = product.index("name") | |
product.delete(key) | |
puts product.inspect.upcase | |
if ! product.has_key?[name, price] | |
print "This product is not in the list.\n" | |
end | |
end | |
when 4 | |
product.each{ |key, value| | |
puts "#{key} - #{value[0]}, #{value[1]}" | |
} | |
end | |
when 5 | |
print "Type a letter to display all the products starting with that letter: " | |
$stdout.flush | |
letter = gets.chomp.upcase | |
product.each do |key, value| | |
if value[0].slice(0,1) == letter | |
puts "#{key} - #{value[0]}, #{value[1]}" | |
end | |
end | |
when 6 | |
product.each { |key, value| } | |
low_price = product.sort.first | |
position = product.index(value[1]) | |
product[value[position]] | |
print "$#{low_price}" | |
high_price = product.sort.last | |
## position = product.index(value[1]) | |
product[key, value[1]] | |
print "$#{high_price}" | |
end | |
when 7 | |
sum = 0 | |
product.each { |key, value| } | |
puts "#{key[1]}" | |
sum += [value[1]] | |
print "The sum of all prices is #{sum}." | |
end | |
when 8 | |
exit | |
end | |
if choice > 8 | |
puts "That\'s not one of the choices." | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment