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)


import java.util.Random
import java.util.Scanner
 
val scan = new Scanner(System.in)
val random = new Random
val (from , to) = (1, 100)
val randomNumber = random.nextInt(to - from + 1) + from
var guessedNumber = 0
printf("The number is between %d and %d.\n", from, to)
 
do {
  print("Guess what the number is: ")
  guessedNumber = scan.nextInt
  if (guessedNumber > randomNumber) println("Your guess is too high!")
  else if (guessedNumber < randomNumber) println("Your guess is too low!")
  else println("You got it!")
} while (guessedNumber != randomNumber)