Question 2

AQA Computer Science June 2018 Paper 1GCSE8 marks

On the specification

2.1
3.2 Programming
2.2
3.2 Programming
2.3
3.2 Programming
2.4
3.2 Programming
2.5
3.2 Programming
2.6
3.2 Programming
2.7
3.2 Programming
2.8
3.2 Programming
Question text

2 The algorithm in Figure 1 has been developed to automate the quantity of dog biscuits to put in a dog bowl at certain times of the day. The algorithm contains an error. • Line numbers are included but are not part of the algorithm. Figure 1 1 time  USERINPUT 2 IF time = 'breakfast' THEN 3 q  1 4 ELSE IF time = 'lunch' THEN 5 q  4 6 ELSE IF time = 'dinner' THEN 7 a  2 8 ELSE 9 OUTPUT 'time not recognised' 10 ENDIF 11 FOR n  1 TO q 12 IF n < 3 THEN 13 DISPENSE_BISCUIT('chewies') 14 ELSE 15 DISPENSE_BISCUIT('crunchy') 16 ENDIF 17 ENDFOR 2.1 Shade one lozenge which shows the line number where selection is first used in the algorithm shown in Figure 1. [1 mark] A Line number 2 B Line number 4 C Line number 9 D Line number 12 2.2 Shade one lozenge which shows the line number where iteration is first used in the algorithm shown in Figure 1. [1 mark] A Line number 1 B Line number 8 C Line number 11 D Line number 13 2.3 Shade one lozenge which shows how many times the subroutine DISPENSE_BISCUIT would be called if the user input is 'breakfast'. [1 mark] A 1 subroutine call B 2 subroutine calls C 3 subroutine calls D 4 subroutine calls 2.4 Shade one lozenge which shows the data type of the variable time in the algorithm shown in Figure 1. [1 mark] A Date/Time B String C Integer D Real 2.5 State how many times the subroutine DISPENSE_BISCUIT will be called with the parameter 'chewies' if the user input is 'lunch'. [1 mark] 2.6 State how many possible values the result of the comparison time = 'dinner' could have in the algorithm shown in Figure 1. [1 mark] 2.7 The programmer realises they have made a mistake. State the line number of the algorithm shown in Figure 1 where the error has been made. [1 mark] 2.8 Write one line of code that would correct the error found in the algorithm in Figure 1. [1 mark]