How to resolve the algorithm Guess the number/With feedback step by step in the Brat 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 Brat 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 Brat programming language
Source code in the brat programming language
number = random 10
p "Guess a number between 1 and 10."
until {
guess = ask("Guess: ").to_i
true? (guess.null? || { guess > 10 || guess < 1 })
{ p "Please guess a number between 1 and 10."}
{ true? guess == number
{ p "Correct!"; true }
{ true? guess < number
{ p "Too low!" }
{ p "Too high!" }
}
}
}
You may also check:How to resolve the algorithm A+B step by step in the 11l programming language
You may also check:How to resolve the algorithm Abbreviations, automatic step by step in the Ruby programming language
You may also check:How to resolve the algorithm Power set step by step in the Nim programming language
You may also check:How to resolve the algorithm Null object step by step in the Modula-3 programming language
You may also check:How to resolve the algorithm Carmichael 3 strong pseudoprimes step by step in the Haskell programming language