Created
February 5, 2020 12:47
-
-
Save mjacobus/38b330542b63bf1abf62bcc28fdf9fb6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| number = rand(100) | |
| guess = nil | |
| puts "Adivinhe o número entre zero e 100:" | |
| while true | |
| print "Que número você escolheu? " | |
| guess = Integer(gets.strip) | |
| if guess == number | |
| puts "Parabéns, você acertou! O número é #{number}" | |
| break | |
| end | |
| if guess < number | |
| puts "Errou. O número sorteado é o maior que #{guess}" | |
| else | |
| puts "Errou. O número sorteado é o menor que #{guess}" | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment