I am currently learning ruby ββand I am stuck with this problem:
Write a deaf grandmother program. No matter what you say to your grandmother (whatever you enter), she should answer HUH ?! SAY, SONNY !, if you do not shout it out (enter all capitals). If you scream, she can hear you and scream back, NO, NOT since 1938! To make your program truly believable, every time your grandmother screams every year; maybe any year in a random order between 1930 and 1950. You cannot stop talking to your grandmother until you start shouting BYE.
This is the code I tried:
puts "Say something to Grandma!" something = gets.chomp while something != "BYE" if something == something.upcase puts "NO, NOT SINCE 19" + (rand(30..50)).to_s + "!" else puts "HUH? SPEAK UP SONNY!" end end
Whenever I do this, the if and else lines just go into an infinite loop. What am I doing wrong here?
user1429496
source share