Jump to content

Guess the number/With feedback: Difference between revisions

Add Plain English
(Updated to compile with Nim 1.4. Removed reference to module "rdstdin" which is not documented.)
(Add Plain English)
Line 2,992:
Guess what number I have: 24
You got it!</pre>
 
=={{header|Plain English}}==
<lang plainenglish>The low number is 1.
 
The high number is 100.
 
To run:
Start up.
Play the guessing game.
Wait for the escape key.
Shut down.
 
To play the guessing game:
Pick a secret number between the low number and the high number.
Write "I chose a secret number between " then the low number then " and " then the high number then "." then the return byte on the console.
Loop.
Ask the user for a number.
If the number is the secret number, break.
If the number is less than the secret number, write " Too low." on the console.
If the number is greater than the secret number, write " Too high." on the console.
Repeat.
Write " Well guessed!" on the console.
 
To ask the user for a number:
Write "Your guess? " to the console without advancing.
Read a string from the console.
If the string is not any integer, write " Guess must be an integer." on the console; repeat.
Convert the string to the number.
If the number is less than the low number, write " Guess can't be lower than " then the low number then "." on the console; repeat.
If the number is greater than the high number, write " Guess can't be higher than " then the high number then "." on the console; repeat.</lang>
{{out}}
<pre>
I chose a secret number between 1 and 100.
 
Your guess? apple
Guess must be an integer.
Your guess? 3.14159
Guess must be an integer.
Your guess? -50
Guess can't be lower than 1.
Your guess? 150
Guess can't be higher than 100.
Your guess? 50
Too high.
Your guess? 25
Too low.
Your guess? 37
Too low.
Your guess? 43
Too low.
Your guess? 46
Too low.
Your guess? 48
Well guessed!
</pre>
 
=={{header|PowerShell}}==
1,808

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.