Question 3
AQA Computer Science November 2021 Paper 1 (8520/1)GCSE10 marks
On the specification
- 3.1
- 3.2 Programming
- 3.2
- 3.2 Programming
- 3.3
- 3.2 Programming
- 3.4
- 3.3 Fundamentals of data representation
Question text
3 box A developer is writing a program to convert a sequence of integers that represent playing cards to Unicode text. The developer has identified that they need to create the subroutines shown in Figure 2 to complete the program. Figure 2 Subroutine Purpose getSuit(n) Returns: • the string 'hearts' if n is 0 • the string 'diamonds' if n is 1 • the string 'spades' if n is 2 • the string 'clubs' if n is 3. getRank(n) Returns the number value of the card as a string, for example: • if n is 1 then 'ace' is returned • if n is 2 then 'two' is returned • if n is 10 then 'ten' is returned • if n is 11 then 'jack' is returned. convert(cards) Returns the complete string representation of the array cards. For example: • if cards is [3, 1], the string returned would be 'three of diamonds ' • if cards is [1, 0, 5, 2, 7, 0], the string returned would be 'ace of hearts five of spades seven of hearts '. 3.1 Explain how the developer has used the structured approach to programming. [2 marks] 3.2 State two benefits to the developer of using the three separate subroutines described box in Figure 2 instead of writing the program without using subroutines. [2 marks] 3.3 Figure 3 shows the subroutine convert described in Figure 2. Some parts of the subroutine have been replaced with the labels L1 to L5. Figure 3 SUBROUTINE convert(cards) result ← '' max ← LEN(cards) index ← 0 WHILE index < L1 rank ← L2(cards[index]) suit ← getSuit(cards[L3 + 1]) c ← rank + ' of ' + suit + ' ' result ← result + L4 index ← index + 2 ENDWHILE RETURN L5 ENDSUBROUTINE State the pseudo-code that should be written in place of the labels in the subroutine written in Figure 3. [5 marks] L1 L2 L3 L4 L5 3 4 box . Shade one lozenge that states why Unicode is now commonly used in preference to ASCII. [1 mark] A Unicode can be represented in hexadecimal. B Unicode includes characters from many different alphabets. C Unicode is a sequential character set. D Unicode is easier to remember than ASCII. E Unicode takes up less space in memory than ASCII. 10