Prompting: Redux! topic problem (step 4)


#1

Hello everybody,
I am stuck at step 4.
Here is my code
movies = { Togpun: 4, Gladiator: 4, Amadeus: 3}
puts "What is your choice"
choice = gets.chomp
case choice
when "add"
puts "Add a movie title"
title = gets.chomp
puts "What is your rating of the movie?"
rating = gets.chomp
movies[title] = rating
puts "Your #{title} has been added and have a rating of#{rating}}
when "update"
puts "Updated!"
when "delete"
puts "Deleted"
else
puts "Error!"
end

and here is the error message I keep getting:
Oops, try again. Did you create a variable called title?

I would very much appreciate your help.
Thanks in advance


#2

I could spot one error and corrected it:
puts "Your #{title} has been added and have a rating of#{rating}}
and replaced it with:
puts "Your #{title} has been added and have a rating of#{rating}"

so now I got over the last error message but get a new one:
Oops, try again. It looks like you didn't add to the movies hash!

any help please?
thanks in advance


#3

Hi, When you click Save and Submit. First type "add'
Then follow the instructions


#4

YOU CAN USE THIS CODE!
movies = {
Matrix: 4.5,
The_Godfather: 5,
Shawshank Redemption: 4,
Godzilla: 2

}

puts "type add to add a movie"
puts "type update to update a movie"
puts "type display to display movies"
puts "type delete to delete a movie"
puts "your choice: ";
choice = gets.chomp

case choice
when 'add'
puts "WHICH MOVIE DO YOU WANT TO ADD??"
title=gets.chomp
puts "GIVE A RATING ON A SCALE OF (1-5) ??? "
rating=gets.chomp
movies[title] = rating
puts "Your #{title} has been added and have a rating of #{rating}"
when 'update'
puts "Updated!"
when 'display'
puts "Movies!"
when 'delete'
puts "Deleted!"
else
puts "Error!"
end
click Save and Submit
type "add'
and follow the instructions.


#5

Thank you guys for your help.


#6

Your code!

My code!

movies = {
Superman: 4,
Batgirl: 3,
Ironman: 1
}
puts "What would you like to do?" # (Add, Update, Display, Delete) <----notice this
choice = gets.chomp.downcase

case choice
when "add"
puts "What movie do you want to add?"
title = gets.chomp
puts "What's the rating? (Type a number 0 to 4.)"
rating = gets.chomp
movies[title] = rating
puts "#{title} has been added with a rating of #{rating}"
when "update"
puts "Updated!"
when "display"
puts "Movies!"
when "delete"
puts "Deleted!"
else
puts "Error!"
end


#7

This was a bloody nightmare! spend almost two hours searching for the answer, finally got it done. You guys are big help. Thank you all.

Basically what I understand from this madness of two hours is that: first prompt is that, we are tell the program, hi I want "add" a movie, so you type "add" in the prompt, which looks in to the "case" options, and locates the "add" section and runs the further prompts like movie title and rating.

Well correct if am wrong...

I guess it will the same thing with the rest of whens....