The algorithm in Figure 2 has been developed to automate the quantity of dog biscuits to put in a dog bowl at certain times of the day - AQA - GCSE Computer Science - Question 3 - 2021 - Paper 1
Question 3
The algorithm in Figure 2 has been developed to automate the quantity of dog biscuits to put in a dog bowl at certain times of the day.
- Line numbers are included ... show full transcript
Worked Solution & Example Answer:The algorithm in Figure 2 has been developed to automate the quantity of dog biscuits to put in a dog bowl at certain times of the day - AQA - GCSE Computer Science - Question 3 - 2021 - Paper 1
Step 1
Shade one lozenge which shows the line number where selection is first used in the algorithm shown in Figure 2.
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
The line where selection is first used is Line 2, as this is where the first IF condition appears.
Step 2
Shade one lozenge which shows the line number where iteration is first used in the algorithm shown in Figure 2.
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
The line where iteration is first used is Line 11, as it is where the FOR loop starts.
Step 3
Shade one lozenge which shows how many times the subroutine DISPENSE_BISCUIT would be called if the user input is 'breakfast' in Figure 2.
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
The subroutine DISPENSE_BISCUIT would be called 1 time because when the input is 'breakfast', q is set to 1.
Step 4
Shade one lozenge which shows the data type of the variable time in the algorithm shown in Figure 2.
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The data type of the variable time is String, as it stores text inputs like 'breakfast', 'lunch', or 'dinner'.
Step 5
State how many times the subroutine DISPENSE_BISCUIT will be called with the parameter 'chewies' if the user input is 'lunch' in Figure 2.
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
The subroutine DISPENSE_BISCUIT will be called 2 times with the parameter 'chewies' if the user input is 'lunch' since 'lunch' sets q to 4.