Discover a wealth of knowledge at Westonci.ca, where experts provide answers to your most pressing questions. Discover in-depth solutions to your questions from a wide range of experts on our user-friendly Q&A platform. Join our platform to connect with experts ready to provide precise answers to your questions in different areas.

4 Two people play a counting game.
The rules of the game are as follows:
The first player starts at 1
Each player may choose one, two or three numbers on their turn and the numbers must be in ascending order
Players take it in turns to choose
The player who chooses "15" loses the game. For example, if the first player chooses three numbers (1, 2, 3) then the second player could choose one number (4), two numbers (4, 5) or three numbers (4,5,6).
The first player then takes another go.
-Write an algorithm using pseudocode that allows two players to play this game.
The algorithm should:
--Alternate between player 1 and player 2
--Ask the player how many numbers they would like to choose, ensuring that this is between 1 and 3
--Display the numbers that the player has chosen Display a suitable message to say --which player has won once the number 15 has been displayed​

Sagot :

Answer:

algorithm should:

--Alternate between player 1 and player 2

--Ask the player how many numbers they would like to choose, ensuring that this is between 1 and 3

An algorithm using pseudocode that allows two players to play the game is:

  1. BEGIN Player One num "1"
  2. ASCENDING order num;
  3. TURN Player One num;
  4. TURN Player Two num;
  5. INCREMENT
  6. IF there is num "15"
  7. THEN
  8. PLAYER loses

What is a Pseudocode?

This refers to the use of plain language to describe the sequence of steps for solving a problem.

Hence, we can see that from the given game rules about the input that is made by a player where he starts at 1 and any player that selects 15 loses the game and there is an increment is displayed in a rough form above.

Read more about pseudocodes here:

https://brainly.com/question/24953880

#SPJ2