michaelee / cs105

CS 105 labs, examples, handouts, etc.

This URL has Read+Write access

michaelee (author)
Thu Nov 05 00:44:40 -0800 2009
commit  c96734dadec858f39359b7e4f45e4090f1ea0792
tree    65f14533fb858100ae505b3ea7566623388db0a6
parent  a3b49756810a8798b364c9490a25f981ad5cfb1c
cs105 / examples / lect10_guess.rb
100644 13 lines (13 sloc) 0.229 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
goal = 1234
guess = -1
while goal != guess
  puts "Enter a number:"
  guess = gets.to_i
  if guess < goal
    puts "You guessed too low!"
  elsif guess > goal
    puts "You guessed too high!"
  else
    puts "Right on!"
  end
end