When and then


#1

puts "give ur language"
greeting = gets.chomp

Add your case statement below!

case greeting
when "English" then puts "Hello!"
when "French" then puts "Bonjour!"
when "German" then puts "Guten tag!"
when "Finnish" then puts "Haloo!"
else puts "I dont know that language!"
end

i am giving this code and it says it is no set to default printing.. how do yu set to default printing?


#2

Your code look fine to me, I believe when your prompted "give ur language" you have to enter English, French, German etc just how you have entered it in your code. If you was to type "Spanish" which of course isn't included in your code you'd get the default printing error. Hope this makes sense.


#3

Hi,

I am not sure that the code on the server is executing the student code for this exercise properly. My code below produces output, asks a question, and when I enter English, it gives the following error message:

  • Oops, try again. It looks like your program doesn't puts 'Hello!' when greeting == 'English'.

code ->

print "Hello there! Please state preferred language: "
greeting = gets.chomp

case greeting
when "English" then puts "Hello!"
when "French" then puts "Bonjour!"
when "German" then puts "Guten Tag!"
when "Finnish" then puts "Haloo!"
else puts "I don't know that language!"
end