You are on page 1of 17

1.

Peter, John and Andrew have set up a computer system using the following items:
item quantity
central processing unit 1
hard disk 1
printer 1
visual display unit 3
COMIX (a multi-user operating system) 1
Keyboard 3
main memory 1

(a) Which of the above items are storage devices? (2 marks)


(b) Computer terminals are provided for the users to interact with the system.
Which of the above items should these computer terminals consist of? (2 marks)
(c) State two of the function that COMIX should perform. (2 marks)
(d) Briefly describe how COMIX should handle each of the following situations:
(i) Peter and Andrew want to use the central processing unit at the same time.
(ii) John and Peter want to use the printer at the same time. (2 marks)
(e) Suppose f1, f2, f3 are three files stored on the hard disk and the following table is
used by COMIX for file protection:
file F1 F2 F3
user
John R O N
Peter O N R
Andrew R R O

 code “O” means that user can read and write on file,
 code “R” means that user can read the file only,
 code “N” means that the user can neither read nor write on the file.

(i) Of John, Peter and Andrew, which two can communication with each other directly
though the use of these files? Also describe how the direct communication can
be done.

(ii) By changing two codes, modify the table such that each user can write on one file
only and any two of the users can directly communicate with each other
though the use of these files. (4 marks)
2. A computer uses 6-bit words the represent character and integers.

The integer of character represented is obtained according to the following flowchart:


(a) The following are 6-bit words expressed in denary.
Write down the character or integer represented.
(i) 15
(ii) 26
(iii) 44 (3 marks)

(b) Write down the bit pattern of the 6-bit word representing
(i) the integer 8;
(ii) the integer –15;
(iii) the character “W”. (3 marks)

(c) (i) Write down the smallest integer that can be represented.
(ii) Write down the character of the smallest ASCII value that can be
represented.
(4 marks)

(d) Modify the equation H=K+33 in the flowchart so that the characters represented
include all small letters but no capital letters. (2 marks)
3. Here is a program written in assembly language with the operands represented in
binary codes.
Address Instruction Operand Meaning
Code
0000 INP ---- Input data from input device to accumulator
0001 SUB 1100 Subtract from the contents of accumulator the
contents of address 1100 and store the result
in accumulator

0010 JPN 0101 Branch to address 0101if the contents of


accumulator are less zero
0011 JPZ 0111 Branch to address 0111 if the contents of
accumulator are equal to zero
0100 BRN 0001 Branch unconditionally to address 0001
0101 OUT 1110 Output the contents of address 1110
0110 BRN 1000 Branch unconditionally to address 1000
0111 OUT 1101 Output the contents of address 1101
1000 DEC 1111 Decrease the contents of address 1111 by 1
1001 LOA 1111 Load the contents of address 1111 into the
accumulator
1010 JPP 0000 Branch to address 0000 if the contents of
accumulator are greater then zero
1011 END ---- Stop

The initial contents of addresses 1100, 1101, 1110 and 1111 are 3, 1, 0, and 5
respectively. The input sequence is{2, 3, 6,, 8, 9}.

(a) Complete the following table to show the contents of address 1111,
the output value and the contents of accumulator immediately after the execution
of the instruction at 1000 for each pass.
contents of address output value contents of
1111 accumulator
1 st pass 4 0
2 nd pass
3 rd pass
4 th pass
5 th pass

(6 marks)
(b) If the initial contents of address 1100 are 2 instead of 3, write down the
sequence of output values. (2 marks)
(c) What is the purpose of the program? (2 marks)
(d) (i) If the initial contents of address 1100, 1101, 1110 and 1111 are 3, 1, 0
and if –2 is input, what is the output of the program?
(ii) State one limitation of the program. (2 marks)

4. A factory has installed a computer system to produce pay slips for its workers at the
end of each of each month.
Each day, the time-in and time-out data of each worker are recorded on a timecard
by a clockcard machine. These data will be copied onto a magnetic disk and stored
as a timecard file by a key-to-disc process.
At the end of each month, the computer will validate the timecard file to produce a
validated timecard file. If errors are detected, an error report will be printed for re-
input of data.
After validated, the computer will sort the validated timecard file to produce a sorted
timecard file.
The computer will then retrieve data from the sorted timecard file and the worker
master file to calculate workers’ salaries.
When calculation is completed, the computer will update the worker master file and
print pay slips for the workers.
Draw a system flowchart to illustrate the above process. Your flowchart should:
(i) consist of the following symbols:
(ii) have its symbols labeled with suitable terms from the above paragraphs.
(12 marks)
5. A company uses two files EMPLOYEE and SALARY to store the information about
its employees. The structures of the files are shown as follows.
structure for EMPLOYEE
Field field name
1 NAME
2 ID_CARD_NO
3 SEX
4 DATE_OF_BIRTH
5 ADDRESS
6 TELEPHONE
7 EMPLOYEE_ID

structure for SALARY


Field field name
1 EMPLOYEE_ID
2 WORKING_HR
3 WAGE_PER_HR
(a) Below is a pseudo-code program which prints the corresponding EMPLOYEE_ID
for a given value of ID_CARD_NO:
let the given value be xxx;
open the file EMPLOYEE;
search for the record with ID_CARD_NO = xxx;
if found then
{print ID_CARD_NO;
print EMPLOYEE_ID of the record;}
else print “no record found”;
close the file EMPLOYEE;

Modify and extend the program so that it print the wage of the corresponding
employee for agiven value of ID_CARD_NO. (6 marks)

(b) If the company decides not to use employee identity numbers any more, and
therefore deletes the field EMPLOYEE_ID from EMPLOYEE,
what corresponding change should be made to SALAR? Briefly explain why.
(3 marks)
(c) (i) If one file WORKWE is to be used, instead of two files EMPLOYEE and
SALARY, write down file structure for WORKER so that no information
will be lost.
(ii) Give one disadvantage of using one file WORKER instead of two files
EMPLOYEE and SALARY. (3 marks)
6.Mr Chan works for a transport company in Hong Kong and he often has to travel.
Mr Chan has a microcomputer COMA at his office and a portable computer COMB.
In both COMA and COMB, Mr Chan has installed a modem and a communication
package. He hopes that he can access COMA’s files event when he is overseas.
Next Tuesday Mr Chan will fly to London for a conference. He will definitely take
COMB with him.
(a) If Mr Chan had not installed a modem in COMB, could he access COMA’s files
using COMB when he is in London? Explain your answer. (2 marks)
(b) What must Mr Chan do to COMA before leaving Hong Kong in order to be able to
access files stored on the hard disk of COMA using COMB when he is in London?
(2 marks)
(b) On Tuesday night in a hotel room, Mr Chan starts using COMB.
The following MAIN MENU appears on the screen of COMB:

MAIN MENU:
1. SEND
2. RETRIEVE
3. HELP
4. EDIT
5. DIAL
6. EXIT
Choose one:
(i) Write down the sequence of items of the MAIN MENU that Mr Chan should use
if he wants to edit a stored in COMA.
(ii) COMA and COMB are connected while Mr Chan is editing a file.
State one disadvantage of this.
(iii) When COMA and COMB are disconnected, other people may access COMA’s
files through the telephone line. What security measure might Mr Chan use to
prevent this unauthorized access? (6 marks)

(d) Draw a simple labeled diagram to show how COMB is connected to COMA.
(2 marks)
1. (a) Answer this part using either BASIC or Pascal.

(i) Dry run the above program. Fill in the following table to show the output value
corresponding to each of the input values:
input 2 3 5 6
value
output
value

(ii) The above program was actually written to find the product n(n-1)(n-2)…
…. 1,
where n is a positive integer. However, there are several mistakes in it.
Complete the following table to show the corrections required.
Original program statement Corrected program statement

(iii) Write a program segment to replace the program’s input statement so that
the program accepts positive integers only. If the input integer is not positive,
the program should ask the user to reenter a value by displaying the
message “REENTER PLEASE”. (10 marks)
(b) The diagrams blow show how a linked list of positive values (n1, n2, n3, n4, n5, n6, n7)
is stored in a table.

(i) What is the purpose of the following?


-999
-888
(ii) For each of the following independent cases, fill in the blank boxes with correct
numbers to shown how the new linked list should be stored in the table.

(15 marks)
2. NDATE is program. This program accepts a date of the yare 1993 and output the
date n days after the input date, where n is a positive integer less than 365.
(Note: There are 28 days in both February 1993 and February 1994.)
Below shows sample output of the program.
(In these output, all the information following the question marks is entered through
the keyboard by the user. All other items are output from the
program.)
The program consists of subprogram INT, INPUT_AND_CHECK, CALCULATE
and OUTPUT_DATA. The basic structure of the program is shown as follows:
The variable to be used are listed below:
BASIC Pascal data type meaning
DAYS%(.) Days an array of integer stores the numbers of
days in different
months, e.g.
DAYS%(3) and
days[3] store 31, the
number of days in
March.

MNAME$(.) Mname an array of strings stores the names of


the twelve months,
e.g. MNAME$(3) and
mname[3] store
“March”
C% C an integer loop counter
IPDAY% Ipday an integer the input day
IPMONTH% Ipmonth an integer the input month in
numeral, e.g. 3
represents March

N% N an integer the input number of


days
DAY% Day an integer the output day
MINTH% Month an integer the output month in
numeral, e.g. 3
represents March

YEAR% Year an integer the output year

Using only the above variable, write the following parts the program in either
BASIC of Pascal:
(a) the segment for the declaration of the arrays; (2 marks)
(b) the subprogram INT which initializes the arrays:
for BASIS: DAY%(.) and MNAME$(.),
for Pascal: days and mname; (6 marks)
3.

The diagram above represents a small supermarket. Box a is the area where the
goods are displayed. Box B is the cashier. There is only one cashier and customers
have to wait in a single queue to pay.
Assume that the following three observation are true:
Observation I:
At the start of each time unit, N customers come out from A to join the queue at B,
where N is an integer randomly chosen from (0, 1, 2, 3, 4, 5, 6).
Observation II: Just before the end of each time unit, the cashier completes serving
3 customers if M ≥ 5,
2 customers if M=2. 3 or 4,
1 customer if M=1,
0 customers if M=1,
where M is the number of customers in the queue.
Observation III: No customers leave or join the queue at any other time.

A program is written to simulate the queuing in the supermarket. The program print the
number of customers in the queue at the end of each time unit, as shown in the
sample output below:
Unit(s) of time passed Number of customers in the queue
1 3
2 4
3 3
4 6
‧ ‧
‧ ‧
‧ ‧
The program stops itself when either the number of customers in the queue is
zero for two consecutive units of the time or the number of time units passed
exceeds 2000.
The program consists of subprograms TUNIT, CUSGEN and SERVE. The basic
structure of the program is shown as follows:

Write the following pasts of the program in either BASIC of Pascal:


(a) the subprogram TUNIT which consists of an empty loop of 10000 iterations to
simulate the passing of one time unit; (2 marks)
(b) the subprogram CUSGEN which generates a random integer between 0 and
6 inclusively and adds it to number of customer in the queue; (2 marks)
(You may assume that the BASIC function RND(1) or the Pascal function
random generates a random number greater than 0 and less
than 1. You may use the variable NUM% (for BASIC) or num (for Pascal) to
store the number of customers in the queue.)
(c) the subprogram SERVE which subtracts 0, 1, 2 or 3 from the customers in the
queue according to Observation II: (6 marks)
(You may use the variable PNUM% and NUM% (for BASIC) or pnum and num (for
Pascal) to store the previous and current numbers of current numbers of customers in
the queue respectively.)

(d) the main program. (15 marks)

4. Mary often buys cosmetics in ABC Cosmetics Shop with her ABC card. The card
has a magnetic strip as shown below:

All goods in the shop have a label which looks like the following:

When Mary has selected the goods, she brings them to the cashier, John. John uses
an input device to read the goods labels. The input device is connected to a
microcomputer. The microcomputer obtains the total amount within a second. When
the amount is displayed, John asks Mary for herABC card.
John slides the card over another machine. He then asks Mary to key in her
password. If the password is accepted, a receipt of the following form is printed:

At the end of each month, Mary receives a bill from ABC Cosmetics Shop showing all
the goods she has bought and the amount to be paid. Mary will then send a cheque to
ABC Cosmetics Shopto settle the bill.
Mary is curious about the computer system of ABC Cosmetics Shop. One day, she
meets David, the computer programmer of ABC Cosmetics Shop.
“Could you tell me what information is stored in the goods labels and ABC card?” Mary
asks David.
“Well, the goods label stores the product code and nothing else. The ABC card stores
only one piece of information, and this information is one of the items shown on the
receipt,” David tells Mary.
“But where are the customers passwords stored?” Mary asks.
“The microcomputer keeps a file called PWORD which stores all customers password”
David replies.

(a) (i) Mary often buys from ABC Cosmetics Shop because she likes the payment
system of the shop. Suggest two reason why Mary likes the payment system.
(ii) State two advantages to ABC Cosmetics Shop of using this payment system.
(4 marks)
(b) Name a suitable input device for reading the goods label. (2 marks)
(c) (i) Explain why it is unwise to store the price of goods in the goods label.
(ii) Describe a possible way the microcomputer to obtain the total amount
after the product codes are real. (5 marks)
(d) Which one of the items on the receipt should be stored in the ABC card?
Explain why. (3 marks)

(e) Some of the staff of ABC Cosmetics Shop are allowed to access PWORD.
If the manager wants to prevent them from knowing the password of a customer
by reading PWORE, what security measure should be used? (2 marks)
(f) Suppose ABC Cosmetics Shop has developed into a chain of branch shops
managed by a head office, and further computerization is now required in order
that:
(I) the manager at the head office receives an overall sales analysis report at the
end
of each day, and
(II) customers can use their ABC cards to buy cosmetics at any ABC branch shop.

Describe how ABC Cosmetics Shop should be further computerized. In your


description, specify the hardware and software required and where to install them.
Also include in your description an operating procedure for the computer system to
produce the daily sales analysis report. (9 marks)

You might also like