W
woodyee
Help! I'm stuck! I'm using Chris Pine's book and I'm stuck on the first
exercise at the end of chapter 7 ("Deaf Grandma"). Can someone offer
suggestions? I can get the first part (ask, she yells 'speak up' unless
I ask in caps in that case she'll say 'no...') but I'm lost after that.
Thanks so much!
#Write a Deaf Grandma program.
#Whatever you say to grandma (whatever you type in), she should respond
with HUH?! SPEAK UP, SONNY!,
#unless you shout it (type in all capitals).
#If you shout, she can hear you (or at least she thinks so) and yells
back, NO, NOT SINCE 1938!
#You can't stop talking to grandma until you shout BYE.
#Hint: Don't forget about chomp! 'BYE'with an Enter is not the same as
'BYE' without one!
#Hint 2: Try to think about what parts of your program should happen
over and over again.
#All of those should be in your while loop.
ask = gets.chomp
while ask != ask.upcase
puts 'HUH?! SPEAK UP, SONNY!'
ask = gets.chomp
if ask = ask.upcase
puts 'NO! NOT SINCE 1938'
ask = gets.chomp
end
if puts 'BYE'
ask = gets.chomp
end
end
exercise at the end of chapter 7 ("Deaf Grandma"). Can someone offer
suggestions? I can get the first part (ask, she yells 'speak up' unless
I ask in caps in that case she'll say 'no...') but I'm lost after that.
Thanks so much!
#Write a Deaf Grandma program.
#Whatever you say to grandma (whatever you type in), she should respond
with HUH?! SPEAK UP, SONNY!,
#unless you shout it (type in all capitals).
#If you shout, she can hear you (or at least she thinks so) and yells
back, NO, NOT SINCE 1938!
#You can't stop talking to grandma until you shout BYE.
#Hint: Don't forget about chomp! 'BYE'with an Enter is not the same as
'BYE' without one!
#Hint 2: Try to think about what parts of your program should happen
over and over again.
#All of those should be in your while loop.
ask = gets.chomp
while ask != ask.upcase
puts 'HUH?! SPEAK UP, SONNY!'
ask = gets.chomp
if ask = ask.upcase
puts 'NO! NOT SINCE 1938'
ask = gets.chomp
end
if puts 'BYE'
ask = gets.chomp
end
end