Computer Science (9608) · May/June 2017 · PM 23
Cambridge Computer Science (9608) pm for paper 23, May/June 2017 — 9608/23/M/J/17, file 9608_s17_pm_23.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge International Examinations
Cambridge International Advanced Subsidiary and Advanced Level
9608/23
COMPUTER SCIENCE
Paper 2 Fundamental Problem-solving and Programming Skills
May/June 2017
PRE-RELEASE MATERIAL
* 6 1 8 5 1 1 9 4 1 2 *
No Additional Materials are required.
This material should be given to the relevant teachers and candidates as soon as it has been received
at the Centre.
READ THESE INSTRUCTIONS FIRST
Candidates should use this material in preparation for the examination. Candidates should attempt the
practical programming tasks using their chosen high-level, procedural programming language.
This document consists of 7 printed pages and 1 blank page.
DC (ST) 144370
© UCLES 2017
[Turn over
2
www.dynamicpapers.com
This material is intended to be read by teachers and candidates prior to the June 2017 examination for
9608 Paper 2.
Reminders
The syllabus states:
•
•
there will be questions on the examination paper which do not relate to this pre-release material.
you must choose a high-level programming language from this list:
o
o
o
Visual Basic (console mode)
Python
Pascal / Delphi (console mode)
Note: A mark of zero will be awarded if a programming language other than those listed is used.
Questions on the examination paper may ask the candidate to write:
•
•
•
structured English
pseudocode
program code
A program flowchart should be considered as an alternative to pseudocode for the documenting of an
algorithm design.
Candidates should be confident with:
•
•
the presentation of an algorithm using either a program flowchart or pseudocode
the production of a program flowchart from given pseudocode or the reverse.
There is an Appendix at the end of this document. Some tasks refer you to this information.
There will also be a similar appendix at the end of the question paper.
Declaration of variables
The syllabus document shows the syntax expected for a declaration statement in pseudocode.
DECLARE <identifier> : <data type>
If Python is the chosen language, each variable’s identifier (name) and its intended data type must be
documented using a comment statement.
Structured English – Variables
An algorithm in pseudocode uses variables, which should be declared. An algorithm in structured
English does not always use variables. In this case, the candidate needs to use the information given
in the question to complete an identifier table. The table needs to contain an identifier, data type and
description for each variable.
© UCLES 2017
9608/23/PRE/M/J/17
3
www.dynamicpapers.com
TASK 1 – Stages of a Simple Algorithm
(a) Fundamental algorithmic stages: Input, Process and Output.
TASK 1.1
Describe a range of activities in terms of these three stages.
Draw examples from different areas such as:
•
•
•
Manufacturing
Key focus:
College / School
Input, process, output
Data processing systems
TASK 1.2
Key focus:
Logic statements
Give examples of programming statements that illustrate each of the three stages.
Compare similar statements in pseudocode and high-level languages.
Key focus:
Input,
process,
output
A simple
count-controlled
loop
(b) Appreciate the use of logic statements within an algorithm.
TASK 1.3
Given the following pseudocode assignments:
FlagA
FlagB
FlagC
MyNum
Key focus:
Key focus:
Logic
statements
Different types of loops
TRUE
FALSE
TRUE
27
Key focus:
A
simple
count-controlled loop
Key
focus:
Evaluate the following expressions:
Expression
More interesting loops...
Evaluates to
Key
Key focus:
focus:
FlagA AND FlagB
Different
types
of loops
Pseudocode
array
declaration
FlagB AND FlagC
FlagB OR FlagC
FlagA AND (FlagB OR FlagC)
FlagB AND (NOT FlagB)
Key focus:
Key focus:
More interesting loops...
Algorithm using structured English
(MyNum > 27) AND FlagC
(MyNum >= 27) AND (FlagC = FALSE)
Key
focus:
Key
focus:
Pseudocode array declaration
Pseudocode and program code
Key
Key focus:
focus:
Algorithm
Test data using structured English
© UCLES 2017
9608/23/PRE/M/J/17
Key focus:
focus:
Key
[Turn over
Pseudocode
and
program
code
Create a text file and add data
4
TASK 2 – Programming Basics: Loops
This is the pseudocode for a simple count-controlled loop:
www.dynamicpapers.com
Key focus:
Key
Input,focus:
process, output
Logic statements
Key focus:
A
simple
count-controlled loop
Logic
statements
1 TO 100
FOR Count
OUTPUT Count
ENDFOR
Key focus:
Input, process, output
Key focus:
A simple
count-controlled loop
Key
focus:
TASK 2.1
Different types of loops
Key focus:
Re-write this pseudocode to provide the same functionality using:
Logic statements
1. A post-condition loop
Key focus:
focus:
Key
2. A pre-condition loop
Different
types ofloops...
loops
More interesting
Key focus:
TASK 2.2
A simple count-controlled loop
Modify the solutions from TASK 2.1 to:
Key focus:
focus:
Key
More interesting loops...
1.
2.
Pseudocode array declaration
Prompt for the input of the start and end value.
Key focus:
Output all the numbers between the start and end values that are exactly divisible by 3.
Different types of loops
Key focus:
For the built-in functions list, refer to the Appendix on page 7.Key
focus:array declaration
Pseudocode
Algorithm using structured English
Key focus:
More interesting loops...
Key focus:
focus:
Key
Algorithm using structured English
Pseudocode and program code
Key focus:
Pseudocode array declaration
Key focus:
focus:
Key
Pseudocode and program code
Test data
Key focus:
Algorithm using structured English
Key focus:
focus:
Key
Test data
Create
a text file and add data
Key focus:
Pseudocode and program code
Key focus:
Key focus:
Create
a text file and add data
Append data to an existing file
Key focus:
Test data
Key focus:
Append data to an existing file
Key focus:
Create a text file and add data
© UCLES 2017
9608/23/PRE/M/J/17
Key focus:
Append data to an existing file
5
www.dynamicpapers.com
Key focus:
TASK 3 – Program design and coding
Input, process, output
A string exists in CamelCase format. For example: "ThisIsACamelCaseString".
A procedure is required that will:
•
•
•
•
Key
Key focus:
focus:
Input,
process, output
Logic statements
prompt for the original string
separate each word of the string
store each word in a separate array element
Key focus:
Key
Input,focus:
process, output
Key
focus:
fill unused array elements with a rogue string such as "(Empty)".
A
simple
count-controlled loop
Logic statements
Key focus:
After processing the preceding example, the array contents will look like this:
Input, process, output
Key focus:
focus:
Key
Logic
statements
Key
focus:
A
simple
count-controlled loop
Different types of loops
Key focus:
This
Is
A
Camel
Case
String
(Empty)
(Empty)
(Empty)
(Empty)
Logic statements
Key focus:
A simple count-controlled loop
Key focus:
Key focus:
Different
types ofloops...
loops
More interesting
A simple count-controlled loo
Key focus:
focus:
Key
Different
types of loops
More
interesting
loops...
Pseudocode
array
declaration
Key
focus:
TASK 3.1
Different types of loops
focus:words of the original string.
Use pseudocode to declare the array that can be used to store Key
the separate
Key
focus:
More
interesting
loops...
You can assume that the original string will contain no more than
10 focus:
separate words.
Key
Pseudocode
array
declaration
Algorithm using structured
English
Key
focus:
More
interesting
loops...
TASK 3.2
Express the requirements using structured English.
TASK 3.3
Key focus:
Pseudocode
Key
focus:array declaration
Algorithm
using
English
Pseudocode
andstructured
program
code
Key focus:
Pseudocode array declaratio
Write pseudocode for this design.
For the built-in functions list, refer to the Appendix on page 7. Key focus:
Key
focus:
Algorithm
using structured English
Pseudocode
and program code
Test data
Key focus:
TASK 3.4
Algorithm using structured E
Write program code for this design.
Key focus:
Key
focus:and program code
Pseudocode
Test data
Create
a text file and
addfocus:
data
Key
TASK 3.5
Pseudocode and program co
Amend your program code to print out the contents of the array in a format that is easy to understand.
Key focus:
Key
focus:
Test data
Key
focus:
TASK 3.6
Create
text file
and
add data
Appenda data
to an
existing
file
Key
focus:
Design suitable test data to test the code thoroughly. Justify your choice.
Test data
© UCLES 2017
9608/23/PRE/M/J/17
Key focus:
[Turn over
Create
a text file and add data
Key focus:
Append data to anKey
existing
file
focus:
Key focus:
Key interesting
focus: loops...
More
6
TASK 4 – File handling
www.dynamicpapers.com
Algorithm using structured English
Key focus:
Key focus:array declaration
Pseudocode
The computer system at a sports club maintains a log of attendances
of each
Pseudocode
andmember.
programEach
codetime a
member visits the club, an entry is added to a log file as follows:
•
•
Membership number (6 characters, for example "123456")
Date of visit (8 characters, for example "28/07/15")
Key focus:
Key focus:
Algorithm
using structured English
Test data
The system concatenates these data items and adds them as a single line to the file.
Key focus:
Key focus:and program code
Pseudocode
Create a text file and add data
TASK 4.1
Write pseudocode to create a text file containing log data for a number of attendances by sports club
Key
members. The user will input the two strings described above
andfocus:
these will be concatenated and
Key
focus:
Test
data
added to the file.
Append data to an existing file
The process will repeat until a rogue value is input.
Key focus:
TASK 4.2
Create a text file and add data
Write pseudocode to append a new data line to the existing file.
Key focus:
Append data to an existing file
TASK 4.3
Write pseudocode to output a list of visits made by a member. Prompt the user to input the membership
Key focus:
number and output the date of each visit by that member. If the membership number is not found,
Input, process, output
output a suitable message.
Key focus:
Search for data in a file
Key focus:
Logic
TASK
4.4 statements
Key focus:
Write program code for TASK 4.1 to TASK 4.3.
Input, process, output
Key focus:
A simple count-controlled loop
TASK 4.5
Key focus:
Key focus:
Implement a menu interface
Search for data in a file
Key
Extend
thefocus:
program from TASK 4.4. The program will present a menu to allow the user to repeatedly
add Logic
a new statements
visit (4.2) or print the visits (4.3). Use a suitable input value to terminate the program.
Key focus:
Key focus:
Different types of loops
Key focus:
Implement a menu interface
A simple count-controlled loop
Key focus:
More interesting loops...
© UCLES 2017
Key focus:
Different types of loops
Key focus:
9608/23/PRE/M/J/17
www.dynamicpapers.com
7
Appendix
Built-in functions (pseudocode)
In each function, if the function call is not properly formed, the function returns an error.
MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING
returns string of length y starting at position x from ThisString.
Example: MID("ABCDEFGH", 2, 3) returns string "BCD"
LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING
returns leftmost x characters from ThisString.
Example: LEFT("ABCDEFGH", 3) returns string "ABC"
RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING
returns rightmost x characters from ThisString.
Example: RIGHT("ABCDEFGH", 3) returns string "FGH"
LENGTH(ThisString : STRING) RETURNS INTEGER
returns the integer value representing the length of string ThisString.
Example: LENGTH("Happy Days") returns 10
MOD(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER
returns the integer value representing the remainder when ThisNum is divided by ThisDiv.
Example: MOD(10,3) returns 1
DIV(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER
returns the integer value representing the whole number part of the result when ThisNum is divided
by ThisDiv.
Example: DIV(10,3) returns 3
Operators (pseudocode)
Operator
&
AND
OR
© UCLES 2017
Description
Concatenates (joins) two strings.
Example: "Summer" & " " & "Pudding" produces "Summer Pudding"
Performs a logical AND of two Boolean values.
Example: TRUE AND FALSE produces FALSE
Performs a logical OR of two Boolean values.
Example: TRUE OR FALSE produces TRUE
9608/23/PRE/M/J/17
8
www.dynamicpapers.com
BLANK PAGE
Permission to reproduce items where third-party owned material protected by copyright is included has been sought and cleared where possible. Every
reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the
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 International
Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after
the live examination series.
Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local
Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.
© UCLES 2017
9608/23/PRE/M/J/17