Gcse Computer Science Question Paper 1 v1 23012018
Gcse Computer Science Question Paper 1 v1 23012018
Surname
Forename(s)
Candidate signature
INTERNATIONAL GCSE
COMPUTER SCIENCE
PAPER 1 PROGRAMMING
The questions in this section are about programming and how the Skeleton Program works. You
should not make any changes to the Skeleton Program whilst answering these questions.
0 1 . 1 State the name of a variable in the Skeleton Program that is used to store a
whole number.
[1 mark]
0 1 . 2 State the name of a user-defined subroutine in the Skeleton Program that has
no parameters.
[1 mark]
0 2 Complete the trace table Table 1 below to show the values of the variables as
the Decrypt subroutine is executed, when it is called with the values
CipherText = "JSB" and Key = 4.
You should assume that the characters in CipherText are stored using
ASCII codes. The ASCII codes for capital letters is shown in Table 2 to help
you.
Copy the contents of all the unshaded cells in Table 1 into your Electronic
Answer Document.
[7 marks]
Turn over ►
0 3 Figure 1 is a flowchart for LoadPlainText but it contains some errors.
Start
Input
FileName
Output "Enter
Filename:"
NO Is FileName YES
length > 0
?
Set PlainText to
Open File "Error"
Write
PlainText
to File
Close File
Return value of
FileName
Stop
5
Include the evidence required for your answers to Section B in your Electronic Answer Document.
The questions in this section require you to make changes to the Skeleton Program.
Note that all of the programming questions in Sections B can be answered independently of
each other. Therefore, if you cannot answer one of the questions you can still attempt to
solve later questions.
You are advised to keep a backup copy of the original Skeleton Program so that you can go
back to it if you accidentally make changes to the program which means it can no longer be
compiled/executed while answering the questions in Sections B.
The title CIPHER SYSTEM should be displayed at the top of the menu with a
blank line between it and the existing menu text.
0 4 . 2 SCREEN CAPTURE(S) to show that the title is displayed at the top of the
menu.
[1 mark]
Turn over ►
0 5 The Skeleton Program is to be improved so that the current value of the key is
displayed.
Modify the Main subroutine so that the key value is displayed on the screen
immediately after the DisplayMenu subroutine has been called.
The key value should be displayed in the format The Current Key is X
where X is the value of the variable Key.
Test that your change has worked by running the Skeleton Program.
0 5 . 2 SCREEN CAPTURE(S) to show that the key value is displayed beneath the
menu.
[1 mark]
0 6 The Skeleton Program currently allows any value to be input for the key.
The cipher should only be used with key values between 1 and 25.
Modify the InputKey subroutine so that if the user enters a key value that is
less than 1 or greater than 25:
Test that your changes have worked by running the Skeleton Program and
then:
Modify the Main subroutine so that when the new option R is selected a
random integer between 1 and 25 is assigned into the variable Key.
Test that your changes have worked by running the Skeleton Program and
then:
Ensure that your SCREEN CAPTURE(S) includes the display of the randomly
generated key value beneath menu.
[1 mark]
Turn over ►
0 8 Currently the Skeleton Program encrypts capital letters by shifting them
according to the key value. Other types of characters, such as lowercase
letters and numeric digits are not encrypted and are just copied into the
ciphertext from the plaintext without being changed.
The program is to be improved so that lower case letters are also shifted
according to the key value.
For example, with a key value of 3 the program would currently encrypt the
plaintext Hello Sam as Kello Vam.
After the program has been modified, the same plaintext should be encrypted
as Khoor Vdp when the key value is 3.
Modify the Encrypt subroutine so that lower case letters are encrypted by
shifting them using the key value.
Test that your changes have worked by running the Skeleton Program and
then:
Include the evidence required for your answers to Section C in your Electronic Answer Document.
The questions in this section require you to make changes to the Skeleton Program.
Note that all of the programming questions in Sections C can be answered independently of
each other. Therefore, if you cannot answer one of the questions you can still attempt to
solve later questions.
You are advised to keep a backup copy of the original Skeleton Program so that you can go
back to it if you accidentally make changes to the program which means it can no longer be
compiled/executed while answering the questions in Sections C.
Ciphers such as the one used in the Skeleton Program can be cracked easily
because, for a given key, each letter in the plaintext is converted to the same
letter in the ciphertext every time it occurs.
Your subroutine only needs to count the number of times each upper case
letter occurs, but you can count every character if you prefer to.
And can also output the following counts if you wish, but no extra marks will be
awarded for this:
Character Count
4
. 1
The counts can be displayed in any order and any sensible format.
Turn over ►
Modify the DisplayMenu subroutine so that an extra option A Count
Characters is added as an option.
Modify the Main subroutine so that when the new option A is selected the
CountCharacters subroutine is called and passed the CipherText as a
parameter.
Test that your changes have worked by running the Skeleton Program and
then:
0 9 . 3 SCREEN CAPTURE(S) to show that the count of characters is output for the
ciphertext JBPPXDB JB PLLK
[2 marks]
11
For example, the characters in the plaintext could be treated as pairs, with the
position of the two letters in each pair being swapped over. In this case, the
plaintext CROCODILE would be encrypted as the ciphertext RCCODOLIE, as
show in Figure 2.
Figure 2
Plaintext C R O C O D I L E
Ciphertext R C C O D O L I E
If the plaintext contains an odd number of characters then the last character
cannot be swapped with another so is just added to the end of the ciphertext.
This has happened to the letter E in CROCODILE as it contains 9 characters.
Modify the Main subroutine so that when the new option T is selected:
Test that your changes have worked by running the Skeleton Program and
then:
Turn over ►
Evidence that you need to provide
Include the following in your Electronic Answer Document.
END OF QUESTIONS