Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. price = rand(100)
  2. running = true
  3. counter = 0
  4. while running
  5. puts "Your guess?"
  6. answer = gets.chomp.to_i
  7. if (1..100).to_a.include?(answer)
  8. counter += 1
  9. if answer == price
  10. running = false
  11. elsif answer > price
  12. puts "Too high"
  13. elsif answer < price
  14. puts "Too low"
  15. end
  16. end
  17. end
  18.  
  19. puts "Congratulations! You've won!!!!!! The correct number was #{price}"
  20. puts "It took you #{counter} tries."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement