Difference between revisions of "2010 Old Spec"
(Created page with "=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 u...") |
|||
Line 33: | Line 33: | ||
|} | |} | ||
<br> | <br> | ||
− | |||
==Figure 4== | ==Figure 4== | ||
− | |||
PlayerOneScore = 0<br> | PlayerOneScore = 0<br> | ||
Line 52: | Line 50: | ||
OUTPUT PlayerOneScore<br> | OUTPUT PlayerOneScore<br> | ||
OUTPUT PlayerTwoScore<br> | OUTPUT PlayerTwoScore<br> | ||
− | |||
==What you need to do== | ==What you need to do== | ||
− | |||
#Write a program for the above algorithm. | #Write a program for the above algorithm. | ||
#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. | #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. |
Revision as of 10:36, 29 November 2016
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
Identier | 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
- Write a program for the above algorithm.
- 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.