Question 1 Report
Fig. 1 shows a vending-machine algorithm for choosing a hot drink. The customer enters a number from 1 to 3. The program uses a selection structure to display the chosen drink and then deduct its price from the credit. Number 1 is tea, number 2 is coffee and number 3 is soup. Any other number causes an error message. The machine must not dispense a drink when the input is invalid.
(a) Identify the displayed word for input 2. [1]
(b) State the displayed word for input 3. [1]
(c) Write one input that produces error. [1]
(d) Give the line that first tests whether the input is 2. [1]
(e) Use the figure to state how many recognised drink choices are available. [1]
(a) Input 2 matches the coffee condition, so the displayed word is coffee. [1]
(b) Input 3 matches the next recognised condition, so the displayed word is soup. [1]
(c) An input such as 4 produces error. [1] Any number other than 1, 2 or 3 is valid test data for this route.
(d) The test for input 2 is on line 03: ELSEIF choice = 2 THEN DISPLAY "coffee". [1]
(e) There are 3 recognised drink choices. [1]
Everything you need to excel in your exams