2010 Old Spec

From TRCCompSci - AQA Computer Science
Jump to: navigation, search

Question 6

The variable table, Table 2, and the Structured English algorithm, Figure 4, describe a simplified version of a noughts and crosses match. A match consists of a user-specified number of games. In this simplified version, the two players complete each game on paper and then enter information about the result of each game into a program that totals the number of games won by each player. Assume that all games have a winner –there are no drawn games.


Table 2

Identifier Data Type Purpose
NoOfGamesInMatch Integer Stores the number of games in the match (specified by user)
NoOfGamesPlayed Integer Stores the number of games played so far
PlayerOneScore Integer Stores the number of games won by Player One
PlayerTwoScore Integer Stores the number of games won by Player Two
PlayerOneWinsGame Char Stores a ’Y’ if Player One won the game and ’N’ otherwise


Figure 4

   PlayerOneScore = 0
PlayerTwoScore = 0
OUTPUT "How many games?"
INPUT NoOfGamesInMatch
FOR NoOfGamesPlayed = 1 TO NoOfGamesInMatch Do
OUTPUT "Did Player One win the game (enter Y or N)?"
INPUT PlayerOneWinsGame
IF PlayerOneWinsGame = ’Y’
THEN PlayerOneScore = PlayerOneScore + 1
ELSE PlayerTwoScore = PlayerTwoScore + 1
ENDIF
ENDFOR
OUTPUT PlayerOneScore
OUTPUT PlayerTwoScore


What you need to do

  1. Write a program for the above algorithm.
  2. Test the program by showing the results of a match consisting of three games where Player One wins the first game and Player Two wins the second and third games.