Computer Science · May / June 2021 · Paper 21 · Question 1
0478
As printed in the paper
Show the answer and mark scheme
1(a)(i)[3]
Many correct answers. They must be meaningful and related to Task 1. The names are examples only.
One mark per mark point
ConstantMaxCandidates
Value4
UseThe value of the maximum number of candidates for the election
1(a)(ii)[4]
Many correct answers. They must be meaningful and related to Task 1. The names are examples only.
One mark per mark point
VariableNumberCandidates
UseStoring the number of candidates in the election (for a tutor group)
ArrayCandidateNames
UseStoring the names of the candidates for the election
1(b)[4]
One mark per mark point (Max 4)
MP1
Change the value of the MaxCandidates constant/variable to 8
MP2
Change the input message to state the maximum number of candidates is 8 …
MP3
…how your program changed the input message
MP4
Change the loop limit to up to 8 …
MP5
…how your program changed the loop limit
MP6
Change the validation to allow input up to 8 …
MP7
…how your program changed its validation check
MP8
Change the array size(s) to ensure sufficient capacity to store up to 8 names …
MP9
…how your program changed the array sizes
MP10
Change the counters to ensure votes can be counted for up to 8 candidates …
MP11
…how your program changed its counters
1(c)[5]
Any five from:
MP1
Input with message to enter unique voter number
MP2
Validation of (unique) voter number entered e.g. length check/type check/range check
MP3
Attempt to check if voter number input is in list of possible voters
MP4
Attempt to check if they have already voted
MP5
If voter has already voted, message to warn them they can’t vote
MP6
Attempt at preventing them from voting
MP7
Store voter number in a suitable data structure
Example answer
OUTPUT "Please enter your unique voter number"
INPUT UniqueVoterNumber
FoundFlag ← False
AllNumbersChecked ← False
Counter ← 0
WHILE FoundFlag = False AND AllNumbersChecked = False
IF StudentNumbers[Counter] = ""
THEN
AllNumbersChecked = True
StudentNumbers[Counter] ← UniqueVoterNumber
ELSE
IF UniqueVoterNumber = StudentNumbers[Counter]
THEN
FoundFlag = True
PRINT “Sorry, you have already voted”
ELSE
Counter = Counter + 1
ENDIF
ENDIF
ENDWHILE
IF FoundFlag = False
THEN
OUTPUT "Please enter the code of your chosen candidate"
INPUT Vote
ENDIF
1(d)[4]
Explanation of how the program does the following:
Any four from:
MP1
Find out how many votes in total (for all candidates) were cast in the election.
MP2
For each candidate
MP3
… calculate the percentage of votes
MP4
… excluding abstentions.
MP5
Display the name of each candidate, the number of votes and the percentage of votes they received with appropriate messages.
MP6
Display the number of votes cast and the number of abstentions with appropriate message.
Section B
Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.

