2009 Old Spec
This question is far too simple and this was the first ever exam which required you to program live.
Question 4
The variable table, Table 2, and the Structured English algorithm describes a simplified version of the Guess the Word/Phrase Game.
Table 2
Identifier | Data Type | Purpose |
---|---|---|
NewWord | String | Stores the setter’s word to be guessed |
UserWordGuess | String | Stores a word that is the user’s guess |
Algorithm
OUTPUT "The new word?"
INPUT NewWord
OUTPUT "Your guess?"
INPUT UserWordGuess
IF UserWordGuess IS EQUAL TO NewWord
THEN OUTPUT "CORRECT"
ELSE OUTPUT "INCORRECT"
ENDIF
What you need to do
- Write a program for the above algorithm in the programming language of your choice.
- Test the program as follows:
- Test 1: Input of the new word EAGLE followed by a correct guess.
- Test 2: Input of the new word BEAR followed by an incorrect guess.