Past questions › sdd2023-q28
2023 6 marks Extended response The Software Engineering Project (Year 12) Desk check and debugging (validation)
NESA 2023 HSC Software Design and Development (OLD syllabus) - Section II Question 28, with NESA Marking Guidelines
In a retail business, all product codes must start with an uppercase letter and then be followed by one or more lowercase letters. The algorithm below is designed to validate a product code. It contains errors. Note that Extract(string, start, N) returns N characters from a string, starting from position start. Eg Extract(“Names”, 3, 2) returns “me”. Line numbers have been provided for reference. 10 | BEGIN validate 20 | OK = “F” 30 | Get ProductCode 40 | Len = Number of characters in ProductCode 50 | WHILE OK = “F” AND ProductCode < > “Q” 60 | OK = “T” 70 | IF Extract(ProductCode, 1, 1) is not an uppercase letter THEN 80 | OK = “F” 90 | Display “Not uppercase” 100 | ENDIF 110 | FOR Count = 1 to Len 120 | IF Extract(ProductCode, Count, 1) is not a lowercase letter THEN 130 | OK = “F” 140 | Display “Not all lowercase” 150 | ENDIF 160 | NEXT Count 170 | IF OK = “F” THEN 180 | Display “Invalid code” 190 | Get ProductCode 200 | ENDIF 210 | ENDWHILE 220 | END validate (a) | Perform a desk check of the algorithm using the test data “p3”, “Pad”, “Q”, “X”. | 3 OK | ProductCode | Len | Extracted | Count | Display character (b) | The algorithm contains errors. | 3 Identify TWO errors and suggest how they can be corrected. Refer to line numbers in your answer.
Marking criteria
[Question 28 (a)] Criteria | Marks • Provides a substantially correct desk check | 3 • Provides a partially correct desk check | 2 • Demonstrates some understanding of the algorithm | 1 Criteria | Marks • Identifies TWO errors and suggests ways to correct them | 3 • Identifies ONE error and suggests a way to correct it OR | 2 • Identifies TWO errors • Identifies an error | 1
Sample answer
Sample answer: OK | ProductCode | Len | Extracted | Count | Display character F | p3 | 2 T | p F | Not uppercase p | 1 F | 3 | 2 | Not all lowercase Invalid code F | Pad | P T | P | 1 | Not all lowercase F | a | 2 Invalid code T | Q Note: X is not considered
[Question 28 (b)] Sample answer: At line 110 the FOR/NEXT loop counter should start at 2. The value of Len is not being updated for the next ProductCode. Move line 40 to line 55.