invalid6363
Programmer
hello, i'm new to ruby and i'm trying a to write a simple greeting program that accepts input from the user (user's name) but its not completely working the way i would like it to. It doesn't print out the goodbye messages and doesn't work when nothing is typed in (Hello World should print out).
if someone can help me i would really appreciate it.
Thank you.
Ruby:
#!/usr/bin/env ruby
class SuperGreeter
print "Enter your name: "
@name = gets
# Say hello
if @name == ""
puts "Hello World!"
else
puts "Hello #{@name}"
puts "Nice to meet you."
end
print "Are you staying?[y/n]: "
@answer = gets
# Say Goodbye
if @answer == ""
puts "Goodbye World!"
elsif @answer == "y"
puts "Thanks for sticking around."
elsif @answer == "n"
puts "Goodbye #{@name}, and come back soon!"
end
end
if someone can help me i would really appreciate it.
Thank you.