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

N5 Computing Science 2026 Question 11

15 marks · Selection and logical operators

The character’s status is determined by their current health and food scores using the following rules: • ‘Feeling fine’ — your character has 40 or more food points and 50 or more health points. • ‘Getting tired’ — your character has under 40 food points or under 50 health points. • ‘Help’ — your character has any other combination of points. Using a design technique of your choice, design the code to determine the character’s status. Players collect coins that they can use to buy upgrades. Health 20 coins Pick-axe 15 coins Helmet 10 coins The number of coins collected and spent by a player are stored in the variables coinTotal and coinsSpent. Part of the code for this game is shown below. … Line 13 <player collects coins> Line 14 <player spends coins> Line 15 SET coinTotal TO coinTotal - coinsSpent Line 16 IF coinTotal < 50 THEN Line 17 SET bonusCoins TO 100 / coinTotal Line 18 END IF Line 19 SEND "You have" TO DISPLAY Line 20 SEND bonusCoins TO DISPLAY Line 21 SEND "bonus coins" TO DISPLAY … A player has collected 10 coins and has bought a helmet. The program stops and produces an error at line 17. State the type of error that has occurred at line 17 and explain why this has happened. Type of error Explanation Name the part of the computer architecture that transfers the value of coinTotal from main memory to the processor. Using a programming language of your choice, write the code to combine the outputs in lines 19, 20 and 21 into a single output message that tells the player how many bonus coins they have. A programmer commented on the readability of the program. Explain what is meant by readability. Your answer should refer to one example from lines 15–18 in the code on the previous page. Every day players are given a free spin of a bonus wheel to win more coins. Players will receive between 1 and 15 coins. 12 bonus coins received Using a programming language of your choice, write the code to generate and store a value between 1 and 15 in a variable called bonus. During the software development process, the code must be translated. State the type of translator that should be used when the game is released to the public. In an online game, players control a character in a fantasy world.

Marking scheme

• correct use of if, else if, else • correct conditions for feeling fine (foodpoints >= 40 AND healthpoints >= 50) • correct condition for getting tired (foodpoints <40 OR healthpoints < 50) • all three character statuses as result of a condition Accept correct nested IF. • execution • the program has divided by 0 Also accept runtime. Data bus • display the appropriate message using quotes • bonusCoins variable used between text with appropriate separators Note that the question does not ask for concatenation. • explanation of readability • identify example from Lines 15-18 Do not accept white space or comment lines as they are not within these lines of code. • random function • correct parameters to get numbers 1 to 15 • number generated by above is assigned to bonus variable • compiler

Previous question: N5 Computing Science 2026 Question 10

Next question: N5 Computing Science 2026 Question 12