A night at the movies:Not my type


#1

My code passes, but the integer is zero when I type four.
Here is my code:
movies = {
"Pacific Rim"=>"4",
"Star Wars VII"=> "4",
}
puts movies
choice = gets.chomp
puts "Would you like to add, display, update, or delete?"
case choice
when "add"
puts "What movie would you like to add?"
title = gets.chomp
title= title.to_sym
if movies[title.to_sym].nil?
puts "What do you rate the movie?"
rating = gets.chomp
rating = rating.to_i
movies[title.to_sym] = rating.to_i
puts "#{title} has been added with a rating of #{rating}"
else puts "#{title} already exists"
end
when "update"
puts"Updated!"
when "display"
puts"movies"
when "delete"
puts"Deleted!"
else
puts"Error!"
end


#2

why are you calling to_sym and to_i on each variable twice? once is enough.


#3

This is my code and the 4 doesn't turn into a 0.

movies = {
Memento: 3,
}

puts "What do you wanna do?"
choice = gets.chomp

case choice
when "add"
puts "What is the title?"
title = gets.chomp
title = title.to_sym
puts "And how would you rate it? 1 to 4."
rating = gets.chomp
rating = rating.to_i
movies[title] = rating

when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end