ExamBank Scot · N5 Computing Science question bank · All N5 Computing Science questions

N5 Computing Science 2015 Question 19

10 marks · Data types and structures

The above design should show the type of data being entered by keyboard in Lines 2, 3 and 5. State the most appropriate data types for the following variables. numberOfChickens pricePerKilo fullPrice State the lines of pseudocode that contain conditional statements. State the part of the processor that compares the values in a conditional statement. The program is later improved to store the totalPrice for each month of a year. State the data structure that would be required to store the list of totalPrice values. State the type of loop required to repeat the code in lines 1 to 12 for each month of the year. Explain why this type of loop would be used. Type of Loop Explanation A program is written to calculate the cost of feeding chickens for one month. Chickens eat 5 Kilograms of grain each month. An incomplete design for the program is shown below. RECEIVE numberOfChickens FROM ( ) KEYBOARD RECEIVE pricePerKilo FROM ( ) KEYBOARD RECEIVE fullPrice FROM ( ) KEYBOARD Line 1 SEND “Enter the number of chickens and the cost of grain” TO DISPLAY Line 2 Line 3 Line 4 SEND “Is the grain full price?” TO DISPLAY Line 5 Line 6 IF fullPrice = True THEN Line 7 SET totalPrice TO numberOfChickens *5*pricePerKilo Line 8 END IF Line 9 IF fullPrice = False THEN Line 10 SET totalPrice TO numberOfChickens *5*(pricePerKilo*0.8) Line 11 END IF Line 12 SEND [“The total cost of grain required for” & numberOfChickens & “chickens is £” & totalPrice] TO DISPLAY

Marking scheme

• Line 2 – Integer • Line 3 – Real • Line 5 – Boolean Acceptable answers as per SQA support notes do not allow ‘int’, ‘float’, ‘single’, ‘double’, ‘true/false’ and other similar answers. • Line 6 • Line 9 Accept: • Lines 6 to 8 (1 mark) • Lines 9 to 11 (1 mark) • Lines 6 to 11 (2 marks) as the conditional statement is the complete IF statement. Arithmetic Logic Unit (ALU) An array (1 mark) Of Reals (1 mark) Unconditional/fixed loop (1 mark) The program loops a known (12) number of times. (1 mark) No mark for a ‘for loop’ although candidate may go on to gain a mark for a correct explanation. If candidate can give an appropriate reason for a conditional loop (eg Can loop until the end of an array) award 1 mark.

Previous question: N5 Computing Science 2015 Question 18

Next question: N5 Computing Science 2015 Question 20