Computer Science (0478) · Oct/Nov 2018 · Question paper 21
Cambridge Computer Science (0478) question paper for paper 21, Oct/Nov 2018 — 0478/21/O/N/18, file 0478_w18_qp_21.pdf.
Text of this paper
www.dynamicpapers.com
Cambridge International Examinations
Cambridge International General Certificate of Secondary Education
* 1 6 8 7 9 7 0 8 2 1 *
0478/21
COMPUTER SCIENCE
Paper 2 Problem-solving and Programming
October/November 2018
1 hour 45 minutes
Candidates answer on the Question Paper.
No Additional Materials are required.
No calculators allowed.
READ THESE INSTRUCTIONS FIRST
Write your Centre number, candidate number and name in the spaces at the top of this page.
Write in dark blue or black pen.
You may use an HB pencil for any diagrams, graphs or rough working.
Do not use staples, paper clips, glue or correction fluid.
DO NOT WRITE IN ANY BARCODES.
Answer all questions.
DO NOT ATTEMPT TASKS 1, 2 AND 3 in the pre-release material; these are for information only.
You are advised to spend no more than 40 minutes on Section A (Question 1).
No marks will be awarded for using brand names of software packages or hardware.
Any businesses described in this paper are entirely fictitious.
At the end of the examination, fasten all your work securely together.
The number of marks is given in brackets [ ] at the end of each question or part question.
The maximum number of marks is 50.
This syllabus is approved for use in England, Wales and Northern Ireland as a Cambridge International Level 1/Level 2 Certificate.
This document consists of 14 printed pages and 2 blank pages.
DC (SR/SG) 150262/3
© UCLES 2018
[Turn over
2
www.dynamicpapers.com
Section A
You are advised to spend no longer than 40 minutes answering this section.
Here is a copy of the pre-release material.
DO NOT attempt Tasks 1, 2 and 3 now.
Use the pre-release material and your experience from attempting the tasks before the examination to
answer Question 1.
Pre-release material
You are working at a local take-away shop and you have decided to write a program to track daily
takings and profit. Here is the menu:
Menu item
Price
French fries
$2.00
1/4 pound burger
$5.00
1/4 pound cheeseburger
$5.55
1/2 pound burger
$7.00
1/2 pound cheeseburger
$7.50
Medium pizza
$9.00
Medium pizza with extra toppings
$11.00
Large pizza
$12.00
Large pizza with extra toppings
$14.50
Garlic bread
$4.50
Write and test a program or programs.
•
•
•
Your program or programs must include appropriate prompts for the entry of data.
Error messages and other output need to be set out clearly and understandably.
All variables, constants and other identifiers must have meaningful names.
You will need to complete these three tasks. Each task must be fully tested.
TASK 1 – Setting up the menu.
Set up a series of arrays to store the menu items and the prices, using the data supplied in the
menu. Devise an item code for each menu item and store these in another array. Output a new
menu including the item codes so that customers can place an order using the item codes.
TASK 2 – Placing an order.
Extend the program so that when a customer places their order from the menu you enter each item
code and the quantity. When the order is completely entered, a unique order code is generated.
Display the order ensuring that the unique order code, menu items and quantities are shown, along
with the item prices and the total cost of the order. Set up arrays for the day to store the unique order
code and the total cost of each order.
TASK 3 – Calculating daily takings and profit.
10% of the takings are profit. Extend the program to display the total daily takings and profit.
Modify your program to allow you to enter the percentage of the takings that are profit. Output the
total daily takings, the profit and the percentage used in the calculation.
© UCLES 2018
0478/21/O/N/18
3
1
www.dynamicpapers.com
(a) All arrays, variables, constants and other identifiers should have meaningful names.
(i)
State the name, data type and use of two arrays you created for Task 1.
Array 1 name
Data type
Use
Array 2 name
Data type
Use
[4]
(ii)
State the name, data type and use of two variables you have created for Task 2.
Variable 1 name
Data type
Use
Variable 2 name
Data type
Use
[4]
© UCLES 2018
0478/21/O/N/18
[Turn over
4
www.dynamicpapers.com
(b) Write an algorithm to enter each item code and quantity. Then when the order is completely
entered, generate a unique order code (part of Task 2), using either pseudocode,
programming statements or a flowchart. You should assume that Task 1 has already been
completed.
© UCLES 2018
0478/21/O/N/18
5
www.dynamicpapers.com
[5]
© UCLES 2018
0478/21/O/N/18
[Turn over
6
www.dynamicpapers.com
(c) Explain how your program calculates the profit using your input (last part of Task 3) with
variable profit percentage and outputs the results. Any programming statements you use in
your answer must be fully explained.
[4]
© UCLES 2018
0478/21/O/N/18
7
www.dynamicpapers.com
(d) State three items of test data you could use in Task 3 to test the input of the percentage profit
value and explain why you chose them.
Your reasons must be different for each item of test data.
Test data 1
Reason
Test data 2
Reason
Test data 3
Reason
[3]
© UCLES 2018
0478/21/O/N/18
[Turn over
8
www.dynamicpapers.com
Section B
2
Six terms associated with programming and six descriptions are listed.
Draw a line to link each term with its most appropriate description.
Term
Description
Top-down design
Pre-written code to include in
your own program to carry out
a common task.
Structure diagram
Shows the steps representing
an algorithm using various
shapes of boxes.
Flowchart
Shows the hierarchy of the
different components which
make up a system.
Pseudocode
Shows the values of variables
as you manually test your
program.
Library routine
Breaks down a system into
successively smaller pieces.
Trace table
Describes a program using a
simplified high-level notation.
[5]
© UCLES 2018
0478/21/O/N/18
9
3
www.dynamicpapers.com
Describe, giving a different example for each, the purpose of these validation checks used in
programming.
Range check
Example
Length check
Example
Type check
Example
[6]
© UCLES 2018
0478/21/O/N/18
[Turn over
10
4
www.dynamicpapers.com
An algorithm is written in pseudocode:
0
Total
1 TO 50
FOR Count
INPUT Num
Total + Num
Total
NEXT Count
OUTPUT Total
(a) Describe the purpose of the algorithm.
[3]
(b) Re-write the algorithm in pseudocode using a different type of loop.
[3]
(c) Describe how you could modify the original algorithm shown at the start of question 4, to
allow any number of inputs.
[2]
© UCLES 2018
0478/21/O/N/18
11
www.dynamicpapers.com
Question 5 starts on page 12.
© UCLES 2018
0478/21/O/N/18
[Turn over
www.dynamicpapers.com
12
5
The flowchart performs a mathematical process on a number input called TestNum
DIV is used to represent integer division e.g. 7 DIV 3 = 2
START
Flag
True
INPUT
TestNum
Num
Yes
TestNum – 1
Is Num =
1?
No
Num
Flag
Is Flag =
True ?
Yes
False
Yes
No
OUTPUT
TestNum
END
© UCLES 2018
0478/21/O/N/18
Is TestNum /
Num = TestNum
DIV Num ?
No
Num – 1
www.dynamicpapers.com
13
(a) Complete the trace table for the input data: 7
Flag
TestNum
Num
OUTPUT
[2]
(b) Complete the trace table for the input data: 6
Flag
TestNum
Num
OUTPUT
[2]
(c) State the purpose of the algorithm in the flowchart.
[1]
© UCLES 2018
0478/21/O/N/18
[Turn over
www.dynamicpapers.com
14
6
The database table, PCSTOCK, is a part of the database in an electronics shop, showing some of
the desktop (DT), tablet (TB) and laptop (LT) computers they have in stock.
PCID
ScreenSize
DT303240
30
32
DT
4000
$5000.00
DT301620
30
16
DT
2000
$4000.00
DT303220
30
DT231610
23
LT191620
19
LT171610
17
DT230820
23
DT190810
19
LT190810
19
LT170805
17
DT230420
23
DT190410
19
LT190410
19
TB100206
10
RAM
32
16
16
16
8
Type
DT
DT
$3000.00
$3000.00
DT
2000
$2000.00
LT
8
LT
1000
1000
$2500.00
$1500.00
LT
1000
DT
2000
$1000.00
1000
$950.00
4
DT
2
TB
4
1000
$4500.00
2000
DT
4
2000
Price
LT
8
8
HDD(GB)
LT
500
1000
64
$1500.00
$1200.00
$750.00
$200.00
(a) Complete the table to show the most appropriate data type for each field based on the data
shown in the table at the start of question 6.
Field
Data type
PCID
ScreenSize
Type
Price
[2]
(b) Using the query-by-example grid, write a query to identify all the desktop computers with a
hard drive larger than 1000 GB. All fields in the table should be shown, sorted in descending
order by price.
Field:
Table:
Sort:
Show:
Criteria:
or:
[4]
© UCLES 2018
0478/21/O/N/18
15
BLANK PAGE
© UCLES 2018
0478/21/O/N/18
www.dynamicpapers.com
16
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 2018
0478/21/O/N/18