transact_charlie

random Number game

Oct 28th, 2011
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  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.  
Advertisement
Add Comment
Please, Sign In to add comment