Advertisement
transact_charlie

random Number Game

Oct 28th, 2011
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # random game
  2.  
  3. x = rand(100)
  4. guess = -1
  5. while guess != x
  6.     puts('Please enter a number between 0 and 99')
  7.     guess = gets.to_i
  8.     puts(guess.to_s + ' is too high!') if guess > x
  9.     puts(guess.to_s + ' is too low!') if guess < x
  10. end
  11.  
  12. puts(x.to_s + ' is the right number!')
  13.  
  14.  
  15.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement