SHARE
TWEET

Untitled

a guest Jul 20th, 2019 69 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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."
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top