How to resolve the algorithm Guess the number/With feedback step by step in the Plain English programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Guess the number/With feedback step by step in the Plain English programming language
Table of Contents
Problem Statement
Write a game (computer program) that follows the following rules:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Guess the number/With feedback step by step in the Plain English programming language
Source code in the plain programming language
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.
You may also check:How to resolve the algorithm Guess the number step by step in the Plain English programming language
You may also check:How to resolve the algorithm Return multiple values step by step in the Plain English programming language
You may also check:How to resolve the algorithm Arithmetic/Integer step by step in the Plain English programming language
You may also check:How to resolve the algorithm Literals/Integer step by step in the Plain English programming language
You may also check:How to resolve the algorithm Loops/Downward for step by step in the Plain English programming language