Photo AI

Question 16 is about a dice game played against a computer - AQA - GCSE Computer Science - Question 16 - 2023 - Paper 1

Question icon

Question 16

Question-16-is-about-a-dice-game-played-against-a-computer-AQA-GCSE Computer Science-Question 16-2023-Paper 1.png

Question 16 is about a dice game played against a computer. The aim of the game is to get as close to a score of 21 as you can, without going over 21. If your score... show full transcript

Worked Solution & Example Answer:Question 16 is about a dice game played against a computer - AQA - GCSE Computer Science - Question 16 - 2023 - Paper 1

Step 1

Design the program structure

96%

114 rated

Answer

Start by outlining the structure of the program. This includes:

  • Initializing the player's score to 0.
  • Creating a loop that will continue to run while the score is less than or equal to 21 and the player chooses to roll again.

Step 2

Rolling the dice

99%

104 rated

Answer

Use the Random class to generate two random numbers, simulating the rolling of two dice. Each number should be between 1 and 6 inclusive. The sum of these two rolls should be added to the player's current score.

Step 3

Updating the player's score

96%

101 rated

Answer

Output the value of each die roll and the updated total score to the player. Ask the player if they would like to roll again. This can be done using a Console.ReadLine() method to capture their input.

Step 4

Game winning and losing conditions

98%

120 rated

Answer

At the end of the game, check the player's final score using conditional statements:

  • If the score is exactly 21, display a winning message.
  • If the score exceeds 21, display a losing message.
  • If the score is less than 21, generate a random number between 15 and 21. Compare this random number against the player's score:
    • If the random number is greater, display a losing message.
    • If the random number is equal to the score, display a winning message.

Join the GCSE students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;