Created
February 22, 2016 21:11
-
-
Save TonyNguyen87/7d7cbefd5a6724561537 to your computer and use it in GitHub Desktop.
Tony Nguyen homework1
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
## computer randomly picks a number | |
## user guesses number higher or lower than the random number | |
## if user guess correct than puts correct | |
def guessgame | |
prng = rand(100) | |
puts "Guess a number between 0-100" | |
input = gets.chomp.to_i | |
until input == prng | |
if input > prng | |
puts "Guess Lower" | |
input = gets.chomp.to_i | |
elsif input < prng | |
puts "Guess Higher" | |
input = gets.chomp.to_i | |
else | |
puts "Correct" | |
end | |
end | |
end | |
guessgame |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment