Question 5 2017 · May-June · Paper 21 · 10 marks
Reveal official mark-scheme answer
Official answer for Question 5
Question 10
Show text version of question
Question 5
time a user successfully logs into the system, the following information is recorded:
Item Information Example data
1 A five character user ID "JimAA"
2 A four character port ID "3456"
3 A fourteen character time and date "08:30Jun012015"
The data items are concatenated to form a single string. Each string is saved as a separate line in the text file.
The example data in the preceding table would result in the following text line in the file:
"JimAA345608:30Jun012015"
The computer system can produce a list of the successful login attempts by a given user.
The file LoginFile.txt is searched for a given user ID and the corresponding data are copied into a 2D array, LoginEvents.
LoginEvents has been declared in pseudocode as:
DECLARE LoginEvents[1 : 1000, 1 : 2] OF STRING
The main steps of the procedure are as follows:
- Input a user ID.
- Search LoginFile.txt for entries with matching user ID.
- For matching entries, copy items 2 and 3 above into the LoginEvents array.
You can assume that:
- the system initialises all elements of LoginEvents to an empty string " ", before it calls
- there will be no more than 1000 successful logins for a single user.
SearchFile
Question 9
Write program code for the procedure SearchFile.
Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.
Programming language ....................................................................................................................
Program code
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
..........................................................................................................................................................
....................................................................................................................................................[10]
Question 10
Why this question appears here
71% assigned-topic match · Programming › Programming basics
Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.
Permanent source page: Educate A Change · From 9608_s17_qp_21.pdf
