Figure 10 shows part of an algorithm that has been written in pseudo-code - AQA - GCSE Computer Science - Question 11 - 2023 - Paper 1
Question 11
Figure 10 shows part of an algorithm that has been written in pseudo-code.
There is an error in the algorithm.
The algorithm should:
- get the start year and end y... show full transcript
Worked Solution & Example Answer:Figure 10 shows part of an algorithm that has been written in pseudo-code - AQA - GCSE Computer Science - Question 11 - 2023 - Paper 1
Step 1
Normal
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Test Data:
startYear: 1995
endYear: 2010
ValidChoice Result: False
Difference Calculation: The start year is valid, and the end year is also valid. The difference is calculated as follows:
difference=endYear−startYear=2010−1995=15
Therefore, the validChoice is False indicating that the input is still being processed.
Step 2
Erroneous
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Test Data:
startYear: 2015
endYear: 2000
ValidChoice Result: False
Difference Calculation: The start year (2015) is not before the end year (2000), therefore, according to the algorithm, it prompts the user with an error. The validChoice remains False, with a difference calculation resulting in:
difference=endYear−startYear=2000−2015=−15
Since there was an error, we consider the difference as -1.
Step 3
Boundary
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Test Data:
startYear: 2000
endYear: 2023
ValidChoice Result: True
Difference Calculation: The start year is set to 2000, which is acceptable (as the algorithm checks if the start year is before 2000 without issue). Thus, there is no error, and the validChoice is True. The difference is calculated as follows: