Question 11

AQA Computer Science June 2023 Paper 1C (8525/1C)GCSE5 marks

On the specification

11.1
3.1 Fundamentals of algorithms3.2 Programming
11.2
3.2 Programming
Question text

11 Figure 10 shows part of an algorithm that has been written in pseudo-code. box There is an error in the algorithm. The algorithm should: • get the start year and end year from the user • check that the start year is before the end year • check that the start year is before 2000 • calculate the difference between the two years after a valid start year has been entered. • Line numbers are included but are not part of the algorithm. Figure 10 1 validChoice  False 2 REPEAT 3 difference  –1 4 OUTPUT 'Enter a start year ' 5 startYear  USERINPUT 6 OUTPUT 'Enter an end year ' 7 endYear  USERINPUT 8 IF startYear ≥ endYear THEN 9 OUTPUT 'Start year must be before end year' 10 ELSE 11 IF startYear < 2000 THEN 12 OUTPUT 'Start year must be before 2000' 13 ELSE 14 validChoice  True 15 ENDIF 16 ENDIF 17 UNTIL validChoice = True 18 difference  endYear - startYear 19 OUTPUT difference 11.1 Table 1 shows three tests used to check the algorithm in Figure 10. box Complete the table to show what the values of the validChoice and difference variables would be for the given test data. [4 marks] Table 1 Test type Test data validChoice difference startYear 1995 Normal endYear 2010 startYear 2015 Erroneous endYear 2000 startYear 2000 Boundary endYear 2023 11.2 The algorithm in Figure 10 contains a logic error on line 11. Describe how the error on line 11 can be corrected. [1 mark]