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

N5 Computing Science 2023 Question 11

11 marks · Development process and analysis

Identify one process carried out by the voting app. A pupil must enter A, B, C or D to cast their vote. State the most suitable data type for storing the vote. Using a design technique of your choice, design a solution that will allow only these values to be entered. The following code displays the number of votes for each candidate. … Line 22 REPEAT 4 TIMES Line 23 < display candidate name and number of votes > Line 24 END REPEAT … Before the code is run it must be translated. Complete the table below to identify the type of translator that should be used for each effect. Type of translator Effect Loop will be translated once and converted into machine code Loop will be translated four times as the program is run After voting is closed three candidates have received the same number of votes. Their names are stored in a data structure called winners. The app uses a predefined function to pick one candidate from winners. Using a programming language of your choice, write the code that will display the name of the winning candidate. Tarvit High School is trialling a voting system to decide their representative for the pupil council. A programmer creates a voting app to allow pupils to cast their vote. The winner is displayed once voting is closed. 2023 Tarvit High School 2023 Tarvit High School Pupil Council Representative Pupil Council Representative Online Vote Current Votes A Jade Hendry Jade Hendry 22 B Lisa Murphy Lisa Murphy 13 C Lukasz Kowalski D Robert Green Lukasz Kowalski 19 C Enter your vote using your keyboard: A, B, C or D Robert Green 21

Marking scheme

Any one of the following: • find winning representative • add votes/running total for each candidate • validate the input Answer should relate to scenario. Do not allow: • calculate total number of votes Character or Char Do not allow string as question states “most suitable” One mark for each design of input validation showing: • conditional loop • correct loop condition for valid data • input of vote inside loop • error message displayed within appropriate if/loop conditions If the loop is missing the start/end of the loop assume that everything above or below the start/end is inside the loop. While = NOT (A or B or C or D) = NOT (A) and NOT (B) and NOT (C) and NOT (D) Until = A or B or C or D One mark each for the following in the correct order: • compiler • interpreter Type of translator Result compiler Loop on line 22-24 will be translated once and converted into machine code interpreter Loop on line 22-24 will be translated multiple times as the program is run One mark for the following code: • random • correct parameters • random number used as winners array index Accept programming language specific versions of random. Example SQARL answers: SEND winners[RANDOM(0,2)] TO DISPLAY or index = RANDOM(0,2) SEND winners[index] TO DISPLAY

Previous question: N5 Computing Science 2023 Question 10

Next question: N5 Computing Science 2023 Question 12