Created
April 9, 2019 16:31
-
-
Save krokrob/a01e6112b274983fad85746b545089d9 to your computer and use it in GitHub Desktop.
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
# compute computer choice | |
random_price = (1..100).to_a.sample | |
guess_price = 0 # initialization | |
until guess_price == random_price | |
# ask user input and put into an integer | |
puts " What price is the object?" | |
guess_price = gets.chomp.to_i | |
# compare the 2 entries | |
if guess_price == random_price | |
puts "You win" | |
elsif guess_price > random_price | |
puts "it's less" | |
else | |
puts "it's more" | |
end | |
end | |
# tell user if it's more or less or if win | |
# repeat the process until the user wins |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment