Last active
August 29, 2015 13:56
-
-
Save laurenkruczyk/9101617 to your computer and use it in GitHub Desktop.
Guessing Game
This file contains 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
x = 47 | |
while true | |
puts "Guess a number between 1 and 100" | |
puts "Guess a number..." | |
number = gets.chomp.to_i | |
if number < 0 || number>100 | |
puts "Invalid input, must enter a number between 1 and 100." | |
end | |
if number > x | |
puts "Too high, try again..." | |
elsif number < x | |
puts "Too low, try again..." | |
else number == x | |
puts "Congratulations, you've guessed the number!" | |
break | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment