Task

Write a game (computer program) that follows the following rules:

 The computer chooses a number between given set limits.
 The player is asked for repeated guesses until the the target number is guessed correctly
 At each guess, the computer responds with whether the guess is:
 higher than the target,
 equal to the target, 
 less than the target,   or
 the input was inappropriate. 


Related task

   Guess the number/With Feedback (Player)


def getInput:int
  s = System.console.readLine()
  Integer.parseInt(s)
end
 
number = int(Math.random() * 10 + 1)
 
puts "Guess the number between 1 and 10"
 
guessed = false
 
while !guessed do
  begin
    userNumber = getInput
    if userNumber == number
      guessed = true
      puts "You guessed it."
    elsif userNumber > number  
      puts "Too high."
    else
      puts "Too low."
    end
  rescue NumberFormatException => e
    puts "Please enter an integer."
  end
end