Data types, records, arrays and abstract data types – A Level Computer Science (9618)
162 questions · page 10 of 11
Question text
4
(a) A procedure LastLines() will:
•
take the name of a text file as a parameter
•
output the last three lines from that file, in the same order as they appear in the file.
Note:
•
Use local variables LineX, LineY and LineZ to store the three lines from the file.
•
You may assume the file exists and contains at least three lines.
Write pseudocode for the procedure LastLines().
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
(b) The algorithm in part (a) is to be amended. The calling program will pass the number of lines
to be output as well as the name of the text file.
The number of lines could be any value from 1 to 30.
It can be assumed that the file contains at least the number of lines passed.
Outline three changes that would be needed.
1 …
…
…
Question text
8
A program allows a user to save passwords used to log in to websites. A stored password is then
inserted automatically when the user logs in to the corresponding website.
A global 2D array Secret of type STRING stores the passwords together with the website domain
name where they are used. Secret contains 1000 elements organised as 500 rows by 2 columns.
Unused elements contain the empty string (""). These may occur anywhere in the array.
An example of a part of the array is:
Array element
Value
Secret[27, 1]
"thiswebsite.com"
Secret[27, 2]
""
Secret[28, 1]
"thatwebsite.com"
Secret[28, 2]
""
Note:
•
For security, the passwords are stored in an encrypted form, shown as "" in the
example.
•
The passwords cannot be used without being decrypted.
•
You may assume that the encrypted form of a password will NOT be an empty string.
The programmer has started to define program modules as follows:
Module
Description
•
Takes two parameters:
○ a string
○ a character
Exists()
•
Performs a case-sensitive search for the character in the string
•
Returns TRUE if the character occurs in the string, otherwise
returns FALSE
•
Takes a password as a parameter of type string
Encrypt()
•
Returns the encrypted form of the password as a string
•
Takes an encrypted password as a parameter of type string
Decrypt()
•
Returns the decrypted form of the password as a string
Note: in a case-sensitive comparison, 'a' is not the same as 'A'.
(a) Write pseudocode for the module Exists().
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
5
A program will store attendance data about each employee of a company.
The data will be held in a record structure of type Employee. The fields that will be needed are as
shown:
Field
Typical value
Comment
EmployeeNumber
123
A numeric value starting from 1
Name
"Smith,Eric"
Format: <last name>','<first name>
Department
"1B"
May contain letters and numbers
Born
13/02/2006
Must not be before 04/02/1957
Attendance
97.40
Represents a percentage
(a) (i)
Write pseudocode to declare the record structure for type Employee.
…
…
…
…
…
…
… [4]
(ii)
A 1D array Staff containing 500 elements will be used to store the employee records.
Write pseudocode to declare the Staff array.
…
… [2]
(b) There may be more records in the array than there are employees in the company. In this
case, some records of the array will be unused.
(i)
State why it is good practice to have a standard way to indicate unused array elements.
…
… [1]
(ii)
Give one way of indicating an unused record in the Staff array.
…
… [1]
(c) A procedure Absentees() will output the EmployeeNumber and the Name of all employees
who have an Attendance value of 90.00 or less.
Write pseudocode for the procedure Absentees().
Assume that the Staff array is global.
…
…
…
…
…
…
…
Question text
7
The following pseudocode represents an algorithm intended to output the last three lines as they
appear in a text file. Line numbers are provided for reference only.
10
PROCEDURE LastLines(ThisFile : STRING)
11
DECLARE ThisLine : STRING
12
DECLARE Buffer : ARRAY[1:3] OF STRING
13
DECLARE LineNum : INTEGER
1
14
LineNum
15
OPENFILE ThisFile FOR READ
16
17
WHILE NOT EOF(ThisFile)
18
READFILE Thisfile, ThisLine // read a line
ThisLine
19
Buffer[LineNum]
LineNum + 1
20
LineNum
21
IF LineNum = 4 THEN
1
22
LineNum
23
ENDIF
24
ENDWHILE
25
26
CLOSEFILE ThisFile
1 TO 3
27
FOR LineNum
28
OUTPUT Buffer[LineNum]
29
NEXT LineNum
30
ENDPROCEDURE
(a) There is an error in the algorithm. In certain cases, a text file will have at least three lines but
the output will be incorrect.
(i)
State how the output may be incorrect.
…
… [1]
(ii)
Describe the error in the algorithm and explain how it may be corrected.
Description …
…
…
…
Explanation …
…
…
…
[4]
(b) The original algorithm is implemented and sometimes the last three lines of the text file are
output correctly.
State the condition that results in the correct output.
…
… [1]
(c) Lines 20 to 23 inclusive could be replaced with a single pseudocode statement.
Write the pseudocode statement.
…
… [2]
Question text
1
The text file HighScore.txt stores the players who have scored the top ten scores in a game,
in descending order of score. The file stores the 3-character name of the player, and their integer
score, in the order: player, score.
For example, the current top player in the text file:
FYI is the player name
10 000 is the score
The program:
•
reads in the data from HighScore.txt
•
allows the user to enter a new player name and their score
•
if appropriate, inserts the new player (name and score) into the top ten
•
writes the top ten players (name and score) into a new text file NewHighScore.txt
(a) The program stores the players and their scores in an array of 11 elements (10 elements to
be read from the file, 1 element to be inserted by the user).
Write a program to declare one or more arrays, as global data structures, to store the player
names and their scores.
Save your program as Question1_J2022.
Copy and paste the program code into part 1(a) in the evidence document.
[2]
(b) The procedure ReadHighScores() opens the file HighScore.txt and reads the data into
the data structure(s) declared in part 1(a).
Write program code to declare the procedure ReadHighScores().
Save your program.
Copy and paste the program code into part 1(b) in the evidence document.
[6]
(c) The procedure OutputHighScores() outputs all the values in the data structure(s) in the
format:
PlayerName Score
For example, the first two data items:
FYI 10 000
ABC 9 092
Write program code to declare the procedure OutputHighScores().
Save your program.
Copy and paste the program code into part 1(c) in the evidence document.
[3]
(d) The main program should first call ReadHighScores() and then OutputHighScores().
(i)
Write the program code for the main program.
Save your program.
Copy and paste the program code into part 1(d)(i) in the evidence document.
[2]
(ii)
Test your program.
Take a screenshot to show the output from part 1(d)(i).
Copy and paste the screenshot into part 1(d)(ii) in the evidence document.
[1]
(e) The main program needs to ask the user to input a new player name and a score. If this score
is in the top ten then it will create a new top ten list that includes this score.
(i)
Amend the main program to ask the user to input a 3-character player name and an
integer score that must be between 1 and 100 000 inclusive.
Save your program.
Copy and paste the program code into part 1(e)(i) in the evidence document.
[3]
(ii)
Write program code to declare a procedure that:
•
takes the player name and score as parameters
•
creates a new top ten list that includes the parameter if appropriate.
Save your program.
Copy and paste the program code into part 1(e)(ii) in the evidence document.
[5]
(iii)
Amend the main program to call the procedure from part 1(e)(ii).
Output the contents of the array before inserting the new player name and score, and
output the contents of the array after inserting the new player name and score.
Save your program.
Copy and paste the program code into part 1(e)(iii) in the evidence document.
[2]
(iv)
Test your program by entering the player name "JKL" and the score "9999".
Take a screenshot to show the output.
Copy and paste the screenshot into part 1(e)(iv) in the evidence document.
[1]
(f)
The procedure WriteTopTen() stores the new top ten player names and scores in a text
file called NewHighScore.txt
Write program code to declare the procedure WriteTopTen().
Save your program.
Copy and paste the program code into part 1(f) in the evidence document.
[4]
Question text
3
A program uses a circular queue to store strings. The queue is created as a 1D array, QueueArray,
with 10 string items.
The following data is stored about the queue:
•
the head pointer initialised to 0
•
the tail pointer initialised to 0
•
the number of items in the queue initialised to 0.
(a) Declare the array, head pointer, tail pointer and number of items.
If you are writing in Python, include attribute declarations using comments.
Save your program as Question3_J2022.
Copy and paste the program code into part 3(a) in the evidence document.
[2]
(b) The function Enqueue is written in pseudocode. The function adds DataToAdd to the queue.
It returns FALSE if the queue is full and returns TRUE if the item is added.
The function is incomplete, there are five incomplete statements.
FUNCTION Enqueue(BYREF QueueArray[] : STRING, BYREF HeadPointer : INTEGER,
BYREF TailPointer : INTEGER, NumberItems : INTEGER,
DataToAdd : STRING) RETURNS BOOLEAN
IF NumberItems = … THEN
RETURN …
ENDIF
← DataToAdd
QueueArray[ … ]
IF TailPointer >= 9 THEN
← …
TailPointer
ELSE
← TailPointer + 1
TailPointer
ENDIF
← NumberItems …
NumberItems
RETURN TRUE
ENDFUNCTION
Write program code for the function Enqueue().
Save your program.
Copy and paste the program code into part 3(b) in the evidence document.
[7]
(c) The function Dequeue() returns "FALSE" if the queue is empty, or it returns the next data
item in the queue.
Write program code for the function Dequeue().
Save your program.
Copy and paste the program code into part 3(c) in the evidence document.
[6]
(d) (i)
Amend the main program to:
•
take as input 11 string values from the user
•
use the Enqueue() function to add each element to the queue
•
output an appropriate message to state whether each addition was successful, or
not
•
call Dequeue() function twice and output the return value each time.
Save your program.
Copy and paste the program code into part 3(d)(i) in the evidence document.
[5]
(ii)
Test your program with the input data:
"A" "B" "C" "D" "E" "F" "G" "H" "I" "J" "K"
Take a screenshot to show the output.
Copy and paste the screenshot into part 3(d)(ii) in the evidence document.
[1]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Question text
1
A program needs to use a stack data structure. The stack can store up to 10 integer elements.
A 1D array StackData is used to store the stack globally. The global variable StackPointer
points to the next available space in the stack and is initialised to 0.
(a) Write program code to declare the array and pointer as global data structures. Initialise the
pointer to 0.
Save your program as Question1_J22.
Copy and paste the program code into part 1(a) in the evidence document.
[3]
(b) Write a procedure to output all 10 elements in the stack and the value of StackPointer.
Save your program.
Copy and paste the program code into part 1(b) in the evidence document.
[3]
(c) The function Push() takes an integer parameter and returns FALSE if the stack is full. If the
stack is not full, it puts the parameter value on the stack, updates the relevant pointer and
returns TRUE.
Write program code for the function Push().
Save your program.
Copy and paste the program code into part 1(c) in the evidence document.
[6]
(d) (i)
Edit the main program to test the Push() function. The main program needs to:
•
allow the user to enter 11 numbers and attempt to add these to the stack
•
output an appropriate message when a number is added to the stack
•
output an appropriate message when a number is not added to the stack if it is full
•
output the contents of the stack after attempting to add all 11 numbers.
Save your program.
Copy and paste the program code into part 1(d)(i) in the evidence document.
[5]
(ii)
Test your program from part 1(d)(i) with the following 11 inputs:
11
12
13
14
15
16
17
18
19
20
21
Take a screenshot to show the output.
Copy and paste the screenshot into part 1(d)(ii) in the evidence document.
[1]
(e) The function Pop() returns −1 if the stack is empty. If the stack is not empty, it returns the
element at the top of the stack and updates the relevant pointer.
(i)
Write program code for the function Pop().
Save your program.
Copy and paste the program code into part 1(e)(i) in the evidence document.
[5]
(ii)
After the code you wrote in the main program for part 1(d)(i), add program code to:
•
remove two elements from the stack using Pop()
•
output the updated contents of the stack.
Test your program and take a screenshot to show the output.
Copy and paste the screenshot into part 1(e)(ii) in the evidence document.
[2]
Question text
2
A 2D array stores data entered by a user.
(a) The main program declares a 2D array of 10 by 10 integer elements.
The array is initialised with a random number between 1 and 100 in each element.
Write program code for the main program.
Save your program as Question2_J22.
Copy and paste the program code into part 2(a) in the evidence document.
[4]
(b) The following bubble sort pseudocode algorithm sorts the data in the first dimension of the 2D
array into ascending numerical order.
10
ArrayLength
0 TO ArrayLength - 1
FOR X
0 TO ArrayLength - 2
FOR Y
0 TO ArrayLength - Y - 2
FOR Z
IF ArrayData[X, Z] > ArrayData[X, Z + 1] THEN
ArrayData[X, Z]
TempValue
ArrayData[X, Z+1]
ArrayData[X, Z]
TempValue
ArrayData[X, Z + 1]
ENDIF
NEXT Z
NEXT Y
NEXT X
(i)
Amend your main program by writing program code to implement the bubble sort
algorithm after the initialisation of the array elements.
You must not use any built-in sorting functions for your programming language.
Save your program.
Copy and paste the program code into part 2(b)(i) in the evidence document.
[5]
(ii)
Write program code for a procedure to output all the values in the 2D array. The values
should be output as a 2D grid, with values in rows and columns.
Call the procedure before and after your bubble sort code.
Save your program.
Copy and paste the program code into part 2(b)(ii) in the evidence document.
[3]
(iii)
Test your program.
Take a screenshot to show the output.
Copy and paste the screenshot into part 2(b)(iii) in the evidence document.
[1]
(c) The following pseudocode function uses recursion to perform a binary search in the first row
of the array, for the value SearchValue in the array SearchArray.
The function returns −1 if the item was not found, or it returns the index where it is found.
There are six incomplete statements.
FUNCTION BinarySearch(SearchArray, Lower, Upper, SearchValue)RETURNS
INTEGER
IF Upper >= Lower THEN
(Lower + (Upper – 1)) DIV …
Mid
IF SearchArray[0, Mid] = … THEN
RETURN …
ELSE
IF SearchArray[0, Mid] > SearchValue THEN
RETURN BinarySearch(SearchArray, … , Mid – 1,
SearchValue)
ELSE
RETURN BinarySearch(SearchArray, Mid + 1, … ,
SearchValue)
ENDIF
ENDIF
ENDIF
RETURN …
ENDFUNCTION
Note: the arithmetic operator DIV performs integer division, e.g. the result of 10 DIV 3 will be 3.
(i)
Write program code for the recursive function BinarySearch().
Save your program.
Copy and paste the program code into part 2(c)(i) in the evidence document.
[8]
(ii)
In the main program, test the function BinarySearch() twice, outputting the returned
value each time.
One test should be for a number that is in the first line of the array.
One test should be for a number that is not in the first line of the array.
Take a screenshot to show the output.
Copy and paste the screenshot into part 2(c)(ii) in the evidence document.
[2]
Question text
3
A programmer is designing a computer game that uses a set of cards.
Each card has a number and a colour. The cards are saved in the text file CardValues.txt
The program has a class named Card. The class has the following attributes and methods.
Card
Number : INTEGER
The number of the card
Colour : STRING
The colour of the card
Constructor()
Takes two values as parameters and sets them to the private
attributes
GetNumber()
Returns the number of the card
Returns the colour of the card
GetColour()
(a) The constructor takes the number and colour of the card as parameters and sets them to the
private attributes.
Write program code to declare the class Card and its constructor. Do not write any other
methods.
Use your programming language appropriate constructor.
All attributes should be private. If you are writing in Python, include attribute declarations
using comments.
Save your program as Question3_J22.
Copy and paste the program code into part 3(a) in the evidence document.
[5]
(b) The two get methods return the associated attribute.
Write program code for the get methods GetNumber() and GetColour().
Save your program.
Copy and paste the program code into part 3(b) in the evidence document.
[3]
(c) The text file CardValues.txt stores the data for 30 cards, in the order: number, colour.
For example, the first card in the text file:
1 is the number
red is the colour.
A 1D array of type Card is declared to store all the cards read in from CardValues.txt
Write the main program to:
•
declare an array of type Card with 30 elements
•
read in the data for the 30 cards from CardValues.txt and assign each to the array.
Save your program.
Copy and paste the program code into part 3(c) in the evidence document.
[7]
(d) The program needs to allow all players (maximum of 5) to select 4 cards from the 30 available.
A card can only be selected once, so the program needs to record which cards have already
been selected.
The function, ChooseCard():
•
takes as input an integer to represent an array index from 1 to 30
•
validates that the value is between 1 and 30 inclusive
•
checks if the card is available (it has not already been selected)
•
loops until an available card is selected
•
returns the index of the card if it is available.
Amend the program to store which cards have already been selected and write program
code for the function ChooseCard().
Save your program.
Copy and paste the program code into part 3(d) in the evidence document.
[6]
(e) The main program needs to allow one player to select all their 4 cards.
(i)
Amend the main program to:
•
create an array, Player1, for player 1 of type Card
•
ask player 1 to input 4 integers using the function from part 3(d)
•
store the cards in Player1
•
output the number and colour of the 4 cards in Player1.
Save your program.
Copy and paste the program code into part 3(e)(i) in the evidence document.
[5]
(ii)
Test your program with the following test data:
Test 1: 1
5
9
10
Test 2: 2
2
3
4
4
5
Take a screenshot to show the output.
Copy and paste the screenshot into part 3(e)(ii) in the evidence document.
[1]
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
publisher will be pleased to make amends at the earliest possible opportunity.
To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge
Assessment International Education Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download
at www.cambridgeinternational.org after the live examination series.
Cambridge Assessment International Education is part of Cambridge Assessment. Cambridge Assessment is the brand name of the University of Cambridge
Question text
2
(a) An algorithm to sort a 1D array into ascending order is described as follows:
•
move the largest value to the end
•
keep repeating until the array is sorted.
Apply the process of stepwise refinement to this algorithm in order to produce a more detailed
description.
Write the more detailed description using structured English. Your explanation of the
algorithm should not include pseudocode statements.
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
… [6]
(b) The program flowchart shown describes a simple algorithm.
START
Set Count to 1
Set Flag to FALSE
Is Flag =
YES
FALSE AND
Count <= 5 ?
NO
ReBoot()
Set Count to Count + 1
Set Flag to Check()
YES
Is Flag =
FALSE ?
NO
Alert(27)
END
Write pseudocode for the simple algorithm shown on page 6.
…
…
…
…
Question text
3
(a) The diagram below represents a queue Abstract Data Type (ADT) that can hold a maximum
of eight items.
The operation of this queue may be summarised as follows:
•
The front of queue pointer points to the next item to be removed.
•
The end of queue pointer points to the last item added.
•
The queue is circular so that empty storage elements can be reused.
0
Frog
Front of queue pointer
1
Cat
2
Fish
3
Elk
End of queue pointer
4
5
6
7
(i)
Describe how “Octopus” is added to the given queue.
…
…
…
… [2]
(ii)
Describe how the next item in the given queue is removed and stored in the variable
AnimalName.
…
…
…
… [2]
(iii)
Describe the state of the queue when the front of queue and the end of queue pointers
have the same value.
…
… [1]
(b) Some operations are carried out on the original queue given in part (a).
(i)
The current state of the queue is:
0
Frog
1
Cat
2
Fish
3
Elk
4
5
6
7
Complete the diagram to show the state of the queue after the following operations:
Add “Wasp”, “Bee” and “Mouse”, and then remove two data items.
[3]
(ii)
The state of the queue after other operations are carried out is shown:
0
Frog
1
Cat
2
Fish
3
Front of queue pointer
Elk
4
Wasp
5
Bee
6
End of queue pointer
Mouse
7
Ant
Complete the following diagram to show the state of the queue after the following
operations:
Remove one item, and then add “Dolphin” and “Shark”.
0
1
2
3
4
5
6
7
[2]
(c) The queue is implemented using a 1D array.
Describe the algorithm that should be used to modify the end of queue pointer when adding
an item to the queue.
Your algorithm should detect any potential error conditions.
…
…
…
…
…
… [3]
Question text
5
The following data items will be recorded each time a student successfully logs on to the school
network:
Data item
Example data
"CJL404"
Student ID
"Lib01"
Host ID
"08:30, June 01, 2021"
Time and date
The Student ID is six characters long. The other two data items are of variable length.
A single string will be formed by concatenating the three data items. A separator character will
need to be inserted between items two and three.
For example:
"CJL404Lib01<separator>08:30, June 01, 2021"
Each string represents one log entry.
A programmer decides to store the concatenated strings in a 1D array LogArray that contains
2000 elements. Unused array elements will contain an empty string.
(a) Suggest a suitable separator character and give a reason for your choice.
Character …
Reason …
…
[2]
(b) The choice of data structure was made during one stage of the program development life
cycle.
Identify this stage.
… [1]
(c) A function LogEvents() will:
•
take a Student ID as a parameter
•
for each element in the array that matches the Student ID parameter:
◦ add the value of the array element to the existing text file LogFile
◦ assign an empty string to the array element
•
count the number of lines added to the file
•
return this count.
Write pseudocode for the function LogEvents().
…
…
…
…
…
…
…
…
…
…
…
…
…
…
Question text
6
A mobile phone has a touchscreen. The screen is represented by a grid, divided into 800 rows
and 1280 columns.
The grid is represented by a 2D array Screen of type INTEGER. An array element will be set to 0
unless the user touches that part of the screen.
Many array elements are set to 1 by a single touch of a finger or a stylus.
The following diagram shows a simplified touchscreen. The dark line represents a touch to the
screen. All grid elements that are wholly or partly inside the outline will be set to 1. These elements
are shaded.
The element shaded in black represents the centre point.
11
6
A program is needed to find the coordinates (the row and column) of the centre point. The centre
point on the diagram above is row 6, column 11.
Assume:
•
the user may only touch one area at a time
•
screen rotation does not affect the touchscreen.
The programmer has started to define program modules as follows:
Module
Description
• Called with three parameters of type INTEGER:
◦
a row number
SetRow()
◦
the number of pixels to be skipped starting from column 1
(generates test
◦
the number of pixels that should be set to 1
data)
• Sets the required number of pixels to 1
For example, SetRow(3, 8, 5) will give row 3 as in the diagram shown.
• Takes two parameters of type INTEGER:
◦
a row number
◦
a start column (1 or 1280)
• Searches the given row from the start column (either left to right or right to left)
SearchInRow()
for the first column that contains an element set to 1
• Returns the column number of the first element in the given row that is set to 1
• Returns −1 if no element is set to 1
• Takes two parameters of type INTEGER:
◦
a column number
◦
a start row (1 or 800)
• Searches the given column from the start row (either up or down) for the first
SearchInCol()
row that contains an element set to 1
• Returns the row number of the first element in the given column that is set to 1
• Returns −1 if no element is set to 1
(a) Write pseudocode to implement the module SetRow().
…
…
…
…
…
…
…
…
…
…
…
… [5]
(b) The module description of SearchInRow() is provided here for reference.
Module
Description
• Takes two parameters of type INTEGER:
◦
a row number
◦
a start column (1 or 1280)
Question text
3
A programmer is writing a program to help manage clubs in a school.
Data will be stored about each student in the school and each student may join up to three clubs.
The data will be held in a record structure of type Student.
The programmer has started to define the fields that will be needed as shown in the following
table.
Field
Typical value
Comment
StudentID
"CF1234"
Unique to each student
Email
"[email protected]"
Contains letters, numbers and certain symbols
Club_1
1
Any value in the range 1 to 99 inclusive
Club_2
14
Any value in the range 1 to 99 inclusive
Club_3
27
Any value in the range 1 to 99 inclusive
(a) (i)
Write pseudocode to declare the record structure for type Student.
…
…
…
…
…
…
… [3]
(ii)
A 1D array Membership containing 3000 elements will be used to store the student
data.
Write pseudocode to declare the Membership array.
…
… [2]
(iii)
Some of the elements of the array will be unused.
Give an appropriate way of indicating an unused array element.
…
… [1]
(iv)
Some students are members of less than three clubs.
State one way of indicating an unused club field.
…
… [1]
(b) A procedure GetIDs() will:
•
prompt and input the number of a club
•
output the StudentID of all the students who are members of that club
•
output a count of all students in the given club.
Write pseudocode for the procedure GetIDs().
…
…
…
…
…
…
Question text
5
A company has several departments. Each department stores the name, email address and the
status of each employee in that department in its own text file. All text files have the same format.
Employee details are stored as three separate data strings on three consecutive lines of the file.
An example of the first six lines of one of the files is as follows:
File line
Comment
1
First employee name
2
First email address
3
First employee status
4
Second employee name
5
Second email address
6
Second employee status
A procedure MakeNewFile() will:
•
take three parameters as strings:
○ an existing file name
○ a new file name
○ a search status value
•
create a new text file using the new file name
•
write all employee details to the new file where the employee status is not equal to the search
status value
•
count the number of sets of employee details that were in the original file
•
count the number of sets of employee details that were written to the new file
•
produce a summary output.
An example summary output is as follows:
File Marketing contained 54 employee details
52 employee sets of details were written to file NewMarketingList
(a) Write pseudocode for the procedure MakeNewFile().
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…
…