Anonymous user
Guess the number/With feedback (player): Difference between revisions
Guess the number/With feedback (player) (view source)
Revision as of 14:31, 22 August 2019
, 4 years agoScala contribution added.
m (→with positive integers: elided a stray "f".) |
m (Scala contribution added.) |
||
Line 2,734:
}</lang>
=={{header|Scala}}==
<lang Scala>object GuessNumber extends App {
val n = 1 + scala.util.Random.nextInt(20)
println("Guess which number I've chosen in the range 1 to 20\n")
do println("Your guess, please: ")
while (io.StdIn.readInt() match {
case `n` => println("Correct, well guessed!"); false
case guess if (n + 1 to 20).contains(guess) => println("Your guess is higher than the chosen number, try again"); true
case guess if (1 until n).contains(guess) => println("Your guess is lower than the chosen number, try again"); true
case _ => println("Your guess is inappropriate, try again"); true
})
}</lang>
=={{header|Scheme}}==
{{works with|Guile}}
<lang scheme>(define minimum 1) (define maximum 100)
(display "Enter a number from ")(display minimum)
|