Gweru diocese Comp paper2
Gweru diocese Comp paper2
Additional
materials:
CD
TIME 3 hours
This is a purely practical examination. All answers should be printed. Handwritten answers
Will not be marked.
Section A 20 marks
Section B 50 marks
Section C 30 marks
______________________________________________________________________________
This specimen paper consists of 6 printed pages and 2 blank pages.
1 (a) A safety system uses the inputs from three sensors A,B and C.The binary values from
these sensors form the input to a logic circuit.
Sensor A
Sensor B Logic circuit ‘X’ Output X from logic circuit
Sensor C
(i) draw the logic circuit, to represent the above System [7]
2. (a) Produce a flowchart showing the 3 stages of the straight line sequencing
of the fetch-execute cycle, describing each stage [8]
.
←
PAPER 6023/2
Section B [50 marks]
Answer one question from this section.
Factorial of n = n* factorial of n – 1
If n > 1
Otherwise factorial of 0 = I
This function is defined for all positive integers’ i.e whole numbers
greater or equal to zero.
(b) A taxi firm charges £3 for the first mile and £2 for every mile after that.
If there are 5 or more passengers, an extra 50% is added to the price.
(i) Write an algorithm in pseudo code which calculates the cost of a journey. [7]
(c) The names of patients are stored in the one-dimensional (1D) array Patient[ ] of type string. A
separate two-dimensional (2D) array Readings[ ] stores the latest data recorded about each patient.
The array already contains the readings taken by a nurse for each patient:
temperature measured to one decimal place
pulse rate, a whole number.
The hospital number given to the patient is used for the index on both arrays, this is a
value between 1 and 1000 inclusive.
When the data for a patient is checked a warning is given if any of the readings are out of
range. If both readings are out of range, then a severe warning is given.
Write a procedure, using pseudocode or program code that meets the following requirements:
takes the hospital number as a parameter
checks if the number is valid
outputs an error message and exits the procedure if the number is not valid
if the hospital number is valid:
– output the patient’s name
– output ‘Normal readings’ if both the readings are within range
– output ‘Warning’ and the name of the reading e.g. ‘Pulse’ if one reading is out of
range
– output ‘Severe warning’ and the names of the two readings ‘Pulse and
temperature’ if both readings are out of range
– exits the procedure.
You must use pseudocode or program code and add comments to explain how your code works.
You do not need to initialise the data in the arrays. [15]
(d) Write a program code to implement a bubble sort algorithm to input 10
integer elements in an array and sort them in a descending order.
There is a sales tax of 15% imposed on the discounted total amount greater than equal to
150.
You are required to design an appropriate form with the required controls, and write code
to the following:
Read the total Amount from a text box.
Use a SELECT CASE structure to find the appropriate discount percentage, and
compute the Discount Amount accordingly
Compute the Discounted Total Amount
Use an IF… statement to find the appropriate tax rate and apply it on the
Discounted Total Amount to compute the Tax Amount.
Compute the After-Tax Discounted Total Amount
EMPLOYEE_DATA
DEPARTMENT
DEPARTMENT_MANAGER
(i) Give three reasons why the EMPLOYEES database is fully normalized. [3]
(b) Part of the EMPLOYEE_DATA table is shown.
(i) Write a Data Definition Language (DDL) statement to create the EMPLOYEES
database. [2]
(ii) Write a DDL statement to define the table EMPLOYEE_DATA,and declare
EmployeeID as the primary key. [5]
(iii) Write a Data Manipulation Language (DML) statement to return the first name
and last name of all female employees in the department named Finance. [5]
(b) SomeshopsbelongtotheRainbowRetailbuyinggroup.Theybuytheirgoodsfromoneormo
resuppliers.
• A unique shopID
• A single retail specialism(for example, food, electrical, garden).
• A unique supplierID
• A similar single specialism recorded.
Rainbow Retail creates a relational database to record data about the shops and their
suppliers.
The entity relationship (ER) diagram for the relationship between the SHOP and
SUPPLIER tables is shown.
SHOP SUPPLIER
SUPPLIER
[3]
(iii) Complete the following table to show for each database table:
• the primary key
• the foreign key(s) (if any):
° Each table may contain none, one or more foreign key(s).
° For a table with no foreign key, write ‘None’.
• an explanation for the use of any foreign key.
SHOP
SUPPLIER
SHOP–
SUPPLIER
[5]
(iv) The database designer has implemented SUPPLIER. ContactPerson as a secondary
key.
Describe the reason for this. [2]
(v) Write an SQL query to display the shop ID and location of all shops with a
‘GROCERY’ specialism. [3]
(vi) The existing shop with ID 8765 has just used the existing supplier SUP89 for
the first time. [3]
6. (a) Using SQL create the following table.
Table: Member
[10]
(b) Write down an SQL statement to make the MemberID field the primary key. [2]
(c) AutoShop is a company that services motor vehicles. Each car has an owner and a person
may own more than one vehicle. Each car may be serviced several times, each service is
identified by a jobID.
(i) Draw an ER diagram in 2NF for this database system [7]
(ii) Suggest table listings to store data about
Cars
Car owners
to match your design in (i) above, showing how the relationship between two
entities is established. [8]
(iii) Suggest any three other attributes for the service (other than jobID) and their
datatypes in a table listing. [3]
PAGE