TK Study

Past questions › sdd2021-q26

2021 4 marks Extended response The Software Engineering Project (Year 12) Algorithm design (guessing game)

NESA 2021 HSC Software Design and Development (OLD syllabus) - Section II Question 26, with NESA Marking Guidelines

In a game called Guess My Number, a player plays against the computer. | 4 • The computer generates a random integer, between 1 and 100 inclusive. • The player enters guesses until they are correct or have made 10 guesses. • The output for each guess will be ‘Too high’, ‘Too low’ or ‘Correct’. • After 10 unsuccessful guesses the number is displayed with the message ‘Sorry, too many guesses’. Design an algorithm for this game, using the function RandomNumber to generate a random integer between 1 and 100.

Marking criteria

[Question 26] Criteria | Marks • Provides a substantially correct algorithm that includes the following features: – Generates a valid random integer – Enters guess – Checks guess and displays message – Loops correctly – Exits loop appropriately – Deals with 10 incorrect guesses appropriately • Provides an algorithm that addresses most of the features | 3 • Provides an algorithm that addresses some features | 2 • Shows some understanding of the problem | 1

Sample answer

Sample answer: BEGIN GuessMyNumber NumGuesses = 0 Done = FALSE Num = RandomNumber WHILE Done = FALSE and NumGuesses < 10 Input YourGuess NumGuesses = NumGuesses + 1 IF YourGuess = Num THEN Display “Correct!” Done = TRUE ELSE IF YourGuess > Num THEN Display “Too High!” ELSE Display “Too Low!” ENDIF ENDIF ENDWHILE IF Done = FALSE THEN Display Num , “Sorry, too many guesses” ENDIF END GuessMyNumber

Question page · Practise and get marked