Past questions › sdd2023-q32
2023 8 marks Extended response The Software Engineering Project (Year 12) Test data and algorithm design (date validation)
NESA 2023 HSC Software Design and Development (OLD syllabus) - Section II Question 32, with NESA Marking Guidelines
An algorithm is required to convert a date in DD/MM/YYYY format into its equivalent long date such as 29 October 2023. The entered date will always be 10 characters and in the format DD/MM/YYYY. The date is validated as follows: • the month must be a valid month (from 1 to 12) • the day value must be valid for that month (for example, no more than 28 for February – ignore leap years). (a) | Complete the table with THREE items of test data that test different aspects of | 3 the logic of the algorithm. Test data | Reason for inclusion (b) | Design an algorithm to validate a date in the form DD/MM/YYYY and output the | 5 equivalent long date, eg 29 October 2023. Include all meaningful error messages to assist the user to understand why their entered date is not valid. You may use the following two library routines in your pseudocode: • Extract(string, start, N) eg Extract(“Names”, 3, 2) returns “me” • Value(string) converts a string to its numerical value eg Value(“42”) returns 42. You may use the following two arrays (indexed from 1) in your pseudocode. MonthName | DaysinMonth January | 31 February | 28 March | 31 April | 30 May | 31 June | 30 July | 31 August | 31 September | 30 October | 31 November | 30 December | 31 2023 HIGHER SCHOOL CERTIFICATE EXAMINATION Centre Number Software Design and Development Student Number
Marking criteria
[Question 32 (a)] Criteria | Marks • Provides THREE items of test data for different aspects of the algorithm, with corresponding reasons for inclusion • Provides TWO items of test data for different aspects of the algorithm, with some justification • Demonstrates some understanding of test data relevant to this algorithm | 1 Criteria | Marks • Provides a substantially correct algorithm that addresses the following features: – Validates the inputted date – Uses appropriate data structures and library routines – Outputs the correct long date – Provides meaningful error messages • Provides a substantially correct algorithm that addresses most of the features • Provides an algorithm that addresses some of the features | 3 • Provides an algorithm that attempts to address one of the features | 2 • Demonstrates some understanding of the problem | 1
Sample answer
Sample answer: Test data | Reason for inclusion 01/15/2022 | Check that the month is valid (1−12) 31/06/2023 | Check correct number of days in month 19/04/2022 | Verify that correct long date is produced
[Question 32 (b)] Sample answer: BEGIN date_conversion Get InDate MM = Extract(InDate, 4, 2) Month = Value (MM) DD = Extract(InDate, 1, 2) Days = Value (DD) YYYY = Extract(InDate, 7, 4) validmonth = CheckMonth(Month) IF validmonth THEN validday = CheckDays(Month, Days) IF validday THEN Display DD + “ ” + MonthName(Month) + “ ” + YYYY ELSE Display “Your days” + DD “are not valid for your entered month”; MM ENDIF ELSE Display “Your entered month must be a valid number between 1 and 12” ENDIF END date_conversion BEGIN CheckMonth(MM) flag = 1 IF MM < 1 OR MM > 12 THEN flag = 0 ENDIF RETURN flag END CheckMonth BEGIN CheckDays(Month, Days) flag = 1 IF Days > DaysinMonth(Month) OR Days < 1 THEN flag = 0 END IF RETURN flag END CheckDays