9210 1 QP InternationalComputerScience G 26may23 07 00 GMT

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

INTERNATIONAL GCSE

COMPUTER SCIENCE
Paper 1 Programming

Friday 26 May 2023 07:00 GMT Time allowed: 2 hours


Materials
For this paper you must have access to:
• a computer
• a printer
• appropriate software
• electronic versions of the Skeleton Program and the data file activity.txt
• a hard copy of the Skeleton Program.

Information
• The marks for questions are shown in brackets.
• The maximum mark for this paper is 80.
• No extra time is allowed for printing and collating.
• The question paper is divided into three sections.
• You may use a bilingual dictionary.
• You must not use an English dictionary.
• You are not allowed to use a calculator.

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).
• Include the evidence required for your answers to Sections B and C in your
Electronic Answer Document.
• You must save your Electronic Answer Document at regular intervals.
• The questions in Sections B and C require you to make changes to the Skeleton Program.
• All of the programming questions in Sections B and C can be answered independently of each
other. 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 and C.

Secure all your printed Electronic Answer Document pages together and hand them to the
invigilator.

IB/M/Jun23/E5 9210/1
2

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 your Electronic Answer Document at regular intervals.

The questions in this section are about programming and how the Skeleton Program works.
Do not make any changes to the Skeleton Program when answering these questions.

0 1 . 1 Name a user-defined subroutine in the Skeleton Program that returns a value which
has a data type of real.
[1 mark]

0 1 . 2 Name the two data structures that are used as records in the Skeleton Program.
[2 marks]

0 1 . 3 Describe the data structure used for the variable ActivityLog.


[2 marks]

0 2 This question is about the DisplayActivity subroutine.

0 2 . 1 How many parameters does the DisplayActivity subroutine have?


[1 mark]

0 2 . 2 Definite iteration is used in the DisplayActivity subroutine.

Name the command that is used in DisplayActivity to achieve definite iteration.


[1 mark]

0 2 . 3 The selection statement in the DisplayActivity subroutine has a condition that


controls whether the code contained within the selection statement is executed.

Describe what this condition does.


[2 marks]

IB/M/Jun23/9210/1
3

There are no questions printed on this page

Turn over for the next question

Turn over ►
IB/M/Jun23/9210/1
4

0 3 The SortByDistance subroutine implements a bubble sort algorithm to sort


ActivityLog by distance.

0 3 . 1 Assuming that N = 11, how many times will the condition in the IF statement be
checked when the SortByDistance subroutine in the Skeleton Program is
called?
[1 mark]

The bubble sort algorithm currently used in the Skeleton Program is not as efficient
as it could be. A more efficient bubble sort algorithm is shown, using pseudocode, in
Figure 1.

Figure 1

N  LEN(ActivityLog)
Swapped  True
WHILE Swapped = True
Swapped  False
FOR Index  0 TO N – 2
IF ActivityLog[Index].Distance < ActivityLog[Index + 1].Distance THEN
Temp  ActivityLog[Index]
ActivityLog[Index]  ActivityLog[Index + 1]
ActivityLog[Index + 1]  Temp
Swapped  True
ENDIF
ENDFOR
N  N – 1
ENDWHILE

0 3 . 2 Explain why the pseudocode version of the bubble sort algorithm shown in Figure 1 is
more efficient than the bubble sort currently used in the SortByDistance
subroutine in the Skeleton Program.
[4 marks]

Figure 2 shows a version of the pseudocode in Figure 1 which does not use the
Temp variable and so it will not work correctly.

Figure 2

N  LEN(ActivityLog)
Swapped  True
WHILE Swapped = True
Swapped  False
FOR Index  0 TO N – 2
IF ActivityLog[Index].Distance < ActivityLog[Index + 1].Distance THEN
ActivityLog[Index]  ActivityLog[Index + 1]
ActivityLog[Index + 1]  ActivityLog[Index]
Swapped  True
ENDIF
ENDFOR
N  N – 1
ENDWHILE

IB/M/Jun23/9210/1
5

0 3 . 3 Explain why the use of the variable Temp in the pseudocode in Figure 1 allows items
in the ActivityLog to be swapped, whilst the operation does not work without
Temp in the pseudocode in Figure 2.
[2 marks]

0 3 . 4 What is the minimum number of times the condition in the IF statement will be
checked when the bubble sort algorithm in Figure 1 is carried out and the
ActivityLog contains 11 items?
[1 mark]

0 3 . 5 Explain under what circumstances the minimum number of checks of the condition in
the IF statement will occur when the bubble sort algorithm in Figure 1 is carried out
and the ActivityLog contains 11 items.
[2 marks]

0 4 This question is about the EnterAge subroutine in the Skeleton Program.

The EnterAge subroutine contains a WHILE loop. This loop checks


that the integer value entered is between 10 and 100 inclusive.

The WHILE loop is to be tested to ensure that it works as expected.

The following integer values are used as test data:


200, 9, 67, 101, 120, 95, 8, 102

0 4 . 1 Give two values from the test data listed above which would be suitable as boundary
test data.
[2 marks]

0 4 . 2 Give one value from the test data listed above which would be suitable as normal
test data.
[1 mark]

Turn over for Section B

Turn over ►
IB/M/Jun23/9210/1
6

Section B (Short programming questions)

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

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


the main menu.

The message Personal Fitness Application should be displayed with a


blank line between it and the current message MAIN MENU.

Change the subroutine DisplayMenu so that this message followed by a blank line
is displayed before the current message MAIN MENU.

Test your change has worked by running the Skeleton Program and then:

• enter D

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 5 . 1 All the PROGRAM SOURCE CODE in the subroutine DisplayMenu.


[3 marks]

0 5 . 2 SCREEN CAPTURE(S) showing the results of the requested test.


[1 mark]

IB/M/Jun23/9210/1
7

0 6 The Skeleton Program is to be improved so that it displays an error message each


time the user enters an invalid menu option.

The error message Invalid Menu Option should be displayed each time the
user enters an invalid menu option. This should be displayed before the user enters
their menu option again.

Change the Main subroutine so that the error message is displayed. This should
happen whenever an invalid menu option is entered.

Test your change has worked by running the Skeleton Program and then:

• enter D
• then enter A
• then enter -1

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 6 . 1 All the PROGRAM SOURCE CODE in the subroutine Main.


[4 marks]

0 6 . 2 SCREEN CAPTURE(S) showing the results of the requested test.


[1 mark]

Turn over for the next question

Turn over ►
IB/M/Jun23/9210/1
8

0 7 The Skeleton Program is to be improved by adding a new menu option that allows
the individual person details to be changed.

Change the DisplayMenu subroutine so that a new menu option


6. Change Individual Person Data is displayed. This new menu option
should appear in an appropriate place.

Change the Main subroutine so that when this new menu option 6 is selected
Individual is updated by calling the EnterUserData subroutine with the
parameter Individual.

Test your changes by running the Skeleton Program and then:

• enter D
• enter 6

No details about an individual need to be entered as part of this test.

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 7 . 1 All the PROGRAM SOURCE CODE in the subroutines DisplayMenu and Main.
[6 marks]

0 7 . 2 SCREEN CAPTURE(S) showing the results of the requested test.


[1 mark]

IB/M/Jun23/9210/1
9

0 8 The Skeleton Program is to be improved by ensuring that when a time is input it is in


the 24-hour time format, for example 17:50

Change the EnterTime subroutine so that it includes additional checks to ensure


that the time entered is in the 24-hour time format. The additional checks should
ensure that:

• the first two digits of the inputted Time string are not above 23
• the last two digits of the inputted Time string are not above 59

The current validation checks should not be changed.

Test your changes by running the Skeleton Program and then:

• enter D
• enter 3
• then enter a day of week number of 2
• then enter a week number of 3
• then enter a time of 26:34
• then enter a time of 20:60
• then enter a time of 20:34

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 8 . 1 All the PROGRAM SOURCE CODE in the subroutine EnterTime.


[10 marks]

0 8 . 2 SCREEN CAPTURE(S) showing the results of the requested test.


[1 mark]

Turn over for Section C

Turn over ►
IB/M/Jun23/9210/1
10

Section C (Longer programming questions)

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

0 9 The Skeleton Program is to be improved by changing the calculation to work out how
many calories are burned when cycling.

The CalculateCalories subroutine needs to be changed so that:

• if the type of activity is cycling then the method described in Figure 3 should be
used to calculate the number of calories burned
• for all other activities the current calculation should still be used
• the new way of calculating calories burned for cycling must be used no matter what
case (upper, lower or mixed) is used to store the activity type. For example, the
activity type could be stored as cycling or CYCLING or Cycling or cYcling.

Figure 3

For females the calories burned while cycling are calculated as follows:
(Age × 0.10 – Weight × 0.07 + AverageHeartRate × 0.43 - 21) × Time ÷ 4

For males the calories burned while cycling are calculated as follows:
(Age × 0.19 + Weight × 0.10 + AverageHeartRate × 0.62 - 56) × Time ÷ 4

Test your changes by running the Skeleton Program and then:

• enter D
• enter 2
• enter 4
• enter cycling

Evidence that you need to provide


Include the following in your Electronic Answer Document.

0 9 . 1 All the PROGRAM SOURCE CODE in the subroutine CalculateCalories.


[11 marks]

0 9 . 2 SCREEN CAPTURE(S) showing the results of the requested test.


[2 marks]

IB/M/Jun23/9210/1
11

1 0 The Skeleton Program is to be improved by adding a new subroutine that allows the
ActivityLog to be searched so that activities above a given distance that occurred
in a specific week are displayed.

Task One
Create a new subroutine called SearchActivity that:

• has a parameter ActivityLog


• displays a message asking the user to enter a distance and allows this value to be
input
• displays a message asking the user to enter the week number and allows this value
to be input
• searches the ActivityLog for all activities that occurred in the required week
where the distance is above the value entered
• for each activity that meets the search criteria output a line that contains:
o day number
o week number
o type of activity
o distance covered during the activity
• displays an appropriate message if no activities were found that matched the
search criteria.

Task Two
Change the DisplayMenu subroutine so that it displays an appropriate menu option
for the new search facility.

Task Three
Change the Main subroutine so that when the new menu option is selected the new
subroutine SearchActivity is called.

Task Four
Test your changes by running the Skeleton Program and then:

• enter D
• enter 2
• enter menu option for the new search facility
• enter a distance of 10
• enter a week number of 3

Evidence that you need to provide


Include the following in your Electronic Answer Document.

1 0 . 1 All the PROGRAM SOURCE CODE for the new subroutine SearchActivity.
[13 marks]

1 0 . 2 All the PROGRAM SOURCE CODE in subroutines DisplayMenu and Main.


[3 marks]

1 0 . 3 SCREEN CAPTURE(S) showing the results of the requested test.


[2 marks]
END OF QUESTIONS

IB/M/Jun23/9210/1
12

There are no questions printed on this page

Copyright information

For confidentiality purposes, all acknowledgements of third-party copyright material are published in a separate booklet. This booklet is published after
each live examination series and is available for free download from www.oxfordaqaexams.org.uk

Permission to reproduce all copyright material has been applied for. In some cases, efforts to contact copyright-holders may have been unsuccessful and
Oxford International AQA Examinations will be happy to rectify any omissions of acknowledgements. If you have any queries please contact the Copyright
Team.

Copyright © 2023 Oxford International AQA Examinations and its licensors. All rights reserved.

*236Y9210/1*
IB/M/Jun23/9210/1

You might also like