0% found this document useful (0 votes)
67 views12 pages

Gcse Computer Science Question Paper 1 v1 23012018

Uploaded by

Kyle Zhang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views12 pages

Gcse Computer Science Question Paper 1 v1 23012018

Uploaded by

Kyle Zhang
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

Less

Please write clearly in block capitals.

Centre number Candidate number

Surname

Forename(s)

Candidate signature

INTERNATIONAL GCSE
COMPUTER SCIENCE
PAPER 1 PROGRAMMING

Specimen 2018 Morning Time allowed: 2 hours


For Examiner’s Use
Materials
Question Mark
For this paper you must have access to:
• a computer 1
• a printer 2
• appropriate software 3
• an electronic version of the Skeleton Program
4
• a hard copy of the Skeleton Program.
Information 5
• The marks for questions are shown in brackets. 6
• The maximum mark for this paper is 80. 7
• No extra time is allowed for printing and collating.
8
• The question paper is divided into three sections.
• You may use a bilingual dictionary. 9
• You may not use an English dictionary. 10
• You are not allowed to use a calculator.
TOTAL
Instructions
• Type the information required on the front of your Electronic Answer Document.
• Answer all questions.
• Enter your answers into the Electronic Answer Document.
• Before the start of the examination make sure your centre number, candidate name and
candidate number are shown clearly in the footer of every page of your Electronic Answer
Document (not the front cover).
Secure all your printed Electronic Answer Document pages and hand them to the
invigilator.
Section A (Non-programming questions)

You are advised to spend no more than 30 minutes on this section.

Type your answers to Section A in your Electronic Answer Document.

You must save this document at regular intervals.

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 1 . 3 State an example of an assignment statement from the Encrypt subroutine.


[1 mark]

0 1 . 4 The Encrypt subroutine uses a FOR loop to achieve definite iteration.


Explain why a FOR loop has been used in this instance instead of a WHILE or
REPEAT loop.
[2 marks]

0 1 . 5 The Encrypt subroutine uses an IF selection statement to test if the


character code of an encrypted letter is greater that the character code of the
letter Z. If it is, 26 is subtracted from the character code.

Explain the purpose of this section of code.


[2 marks]
3

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]

Table 1 – Trace table

CipherText Key CharPos Character CharacterCode PlainText

Table 2 – ASCII codes for capital letters

Letter Code Letter Code Letter Code Letter Code


A 65 H 72 O 79 V 86
B 66 I 73 P 80 W 87
C 67 J 74 Q 81 X 88
D 68 K 75 R 82 Y 89
E 69 L 76 S 83 Z 90
F 70 M 77 T 84
G 71 N 78 U 85

Turn over ►
0 3 Figure 1 is a flowchart for LoadPlainText but it contains some errors.

Describe all of the errors in the flowchart in Figure 1


[5 marks]

Figure 1 – Flowchart for LoadPlainText subroutine with 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

Section B (Short programming questions)

You are advised to spend no more than 45 minutes on this section.

Include the evidence required for your answers to Section B in your Electronic Answer Document.

You must save this document at regular intervals.

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.

0 4 The Skeleton Program is to be improved so that it displays a title at the top of


the menu.

The title CIPHER SYSTEM should be displayed at the top of the menu with a
blank line between it and the existing menu text.

Modify the DisplayMenu subroutine so that the heading is displayed at the


top of the menu with a blank line below it.

Test your change has worked by running the Skeleton Program.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 4 . 1 Your amended PROGRAM SOURCE CODE for the subroutine


DisplayMenu.
[3 marks]

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.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 5 . 1 Your amended PROGRAM SOURCE CODE for the subroutine Main.


[3 marks]

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:

• a suitable error message is displayed which explains what the problem is


• the user is made to reinput a new key value until the value is acceptable.

Test that your changes have worked by running the Skeleton Program and
then:

• select option K to input the key


• enter the key value 36
• enter the key value 0
• enter the key value 25.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 6 . 1 Your amended PROGRAM SOURCE CODE for the subroutine InputKey.


[6 marks]

0 6 . 2 SCREEN CAPTURE(S) to show the result of carrying out the tests.

It should be clear in your SCREEN CAPTURE(S) that no error message is


displayed when the key value of 25 is entered and that the program goes back
to the menu.
[3 marks]
7

0 7 The Skeleton Program is to be extended so that it can choose a key


randomly.

Modify the DisplayMenu subroutine so that an extra option R Random


Key is added as the first menu option.

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:

• select option R to generate a random key value.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 7 . 1 Your amended PROGRAM SOURCE CODE for the subroutine


DisplayMenu.
[1 mark]

0 7 . 2 Your amended PROGRAM SOURCE CODE for the subroutine Main.


[5 marks]

0 7 . 3 SCREEN CAPTURE(S) to show that the key value is randomly generated


when option R is selected.

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:

• select option P to enter the plaintext


• set the plaintext to Hello Sam
• select option E to encrypt the plaintext.

You do not need to modify the Decrypt subroutine.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 8 . 1 Your amended PROGRAM SOURCE CODE for the subroutine Encrypt.


[6 marks]

0 8 . 2 SCREEN CAPTURE(S) to show that when plaintext Hello Sam is encrypted


the ciphertext produced is Khoor Vdp.
[2 marks]
9

Section C (Longer programming questions)

You are advised to spend no more than 45 minutes on this section.

Include the evidence required for your answers to Section C in your Electronic Answer Document.

You must save this document at regular intervals.

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.

0 9 Cracking is attempting to decrypt a ciphertext message without knowing what


key was used to encrypt it.

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.

A useful tool to help crack an encrypted message is to be able to count the


number of occurrences of each character in some ciphertext.

Write a new subroutine called CountCharacters which counts how many


times each character appears in the ciphertext.

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.

For example, for the ciphertext UDFKHO ZHQW RQ D KROLGDB. your


subroutine must output the following counts:

Character Count Character Count


U 1 Q 2
D 3 W 1
F 1 R 2
K 2 L 1
H 2 G 1
O 2 B 1
Z 1

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:

• select option C to enter the ciphertext


• set the ciphertext to JBPPXDB JB PLLK
• select option A to display a count of the number of each character.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 9 . 1 Your amended PROGRAM SOURCE CODE for the subroutine Main.


[3 marks]

0 9 . 2 Your PROGRAM SOURCE CODE for the new subroutine


CountCharacters.
[8 marks]

0 9 . 3 SCREEN CAPTURE(S) to show that the count of characters is output for the
ciphertext JBPPXDB JB PLLK
[2 marks]
11

1 0 A transposition cipher is an alternative type of cipher which encrypts text by


swapping the position of letters in the plaintext to make the ciphertext.

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 DisplayMenu subroutine so that an extra option T Encrypt


Using Transcription Cipher is added as a menu option.

Create a new subroutine EncryptTranspose that will encrypt plaintext


using the method described above.

Your new subroutine should be passed the PlainText as a parameter and


return the CipherText when it is called.

Modify the Main subroutine so that when the new option T is selected:

• the new EncryptTranspose subroutine is called


• PlainText is passed to the subroutine as a parameter
• the value returned by the subroutine is assigned into the CipherText
variable
• the CipherText is displayed on the screen.

Test that your changes have worked by running the Skeleton Program and
then:

• select option P to enter plaintext


• enter the plaintext CROCODILE
• select option T to encrypt the plaintext using the transcription cipher.

Turn over ►
Evidence that you need to provide
Include the following in your Electronic Answer Document.

1 0 . 1 Your PROGRAM SOURCE CODE for the new subroutine


EncryptTranspose.
[10 marks]

1 0 . 2 Your amended PROGRAM SOURCE CODE for the subroutine Main.


[4 marks]

1 0 . 3 SCREEN CAPTURE(S) to show that when plaintext CROCODILE is encrypted


using the transposition method the ciphertext produced is RCCODOLIE.
[2 marks]

END OF QUESTIONS

Copyright © 2018 AQA and its licensors. All rights reserved.

You might also like