Question

Help solve puts "Would you like a random number between 1-13? (y/n)" reply = STDIN.gets if...

Help solve

puts "Would you like a random number between 1-13? (y/n)"

reply = STDIN.gets

if reply == 'y'

                randomNo = 1 + rand(13)

                puts "your number is: " + randomNo

end

                 if randomNo == 13

                                puts "Lucky Number 13!"

else

                puts "Alright, bye!"

              end

0 0
Add a comment Improve this question Transcribed image text
Answer #1

puts "Would you like a random number between 1-13? (y/n)"
reply = STDIN.gets

if reply[0] == "y"
randomNo = 1 + rand(13)
puts "your number is: "
puts randomNo
end
if randomNo == 13
puts "Lucky Number 13!"
else
puts "Alright, bye!"
end

\color{red}\underline{Output:}

Would you like a random number between 1-13? (y/n) your number is: Alright, bye! ni?

\color{red}Please\; upvote\;the \;solution \;if \;it \;helped.\;Thanks!

Add a comment
Know the answer?
Add Answer to:
Help solve puts "Would you like a random number between 1-13? (y/n)" reply = STDIN.gets if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT