1.(a) Below is a list of registers: instruction register, program counter, accumulator, memory data register, memory address register (i) State the functions of any two of the above registers. (ii) Which one of the above register must be initialized when a program begins to run? What initial value will be given to that register? (8 marks) (b) A microcomputer operating system can be stored in either one of the following ways: A – completely in ROM B – partly in ROM and partly on disk Give one advantage of A over B and one advantage of B over A. (4 marks) 2.
Automatic Teller Machines (ATM) are commonly used in Hong Kong nowadays. Customers can withdraw up to $10 000 from an ATM each day. Below are the steps
for
obtaining cash from an ATM: Step 1. insert card Step 2. key in password Step 3. key in amount Step4. take card Step5. take cash (a) Classify each of the above steps as an input or output step. (2 marks) (b) Name four items that should be checked by the computer before a cash withdrawal is allowed. Explain briefly. (6 marks) (c) (i) Write down two features of an interactive system. (ii) Explain why the ATM system should be an interactive system. (4 marks)
3. In a certain computer, each machine instruction is one byte long and following form:
of the
(a) Find the maximum number of different operation codes that can be defined this computer. (2 marks)
for
(b) Below is a machine code program in hexadecimal notation: 9A 70 21 5B EF (i) Rewrite the above program in (A) bit-patterns; (B) operation codes in mnemonics with operands and addresses in binary (ii) If the contents of the address 10102 are 0010 00012, find the contents of the address 10112 after the execution of the program. (You may assume that the accumulator is also one byte long. Your answer should be written in binary.) (iii) What is the purpose of the program? (iv) Which of the digits A, 0, 1, B, F in the above machine code program represent(s) address(es)? (10 marks) 4.
Mary wants to write a program to handle a directory of the telephone numbers and address of her friends. (a) Mary uses an assembly language instead of a high level language to write her program because she wants the program to run faster. (i) Explain why Mary’s program must be translated before it can be run. (ii) Why dose a program written in an assembly language usually run faster than a corresponding program written in a high level language? (iii) Name two disadvantages of writing a program in an assembly language instead of a high level language. (6 marks)
(b) Mary draws the following diagram before she starts writing the program.
(i) Explain how the diagram will make the task of program writing easier for Mary. (ii) When Mary has finished her program, she finds that the program consists of a number of subprograms. Give two reason why it is easier maintain a program consisting of subprograms. (6 marks) 5. (a) Below is a representation of the computer system in a school computer room. This system is used students for writing programs.
(i) Explain why modems are Not required in this system. (ii) Explain how one computer can server three users simultaneously in this system. (iii) Give two reasons why the performance of the system will be improved if each T is replaced by a microcomputer with a hard disk. (8 marks) (b) Give two reasons why a user may prefer using a microcomputer connected in a network to using a stand-alone microcomputer. (4 marks)
6.
A gas company uses a computer system to produce invoices and receipts for its customers.The whole process consists of two stages. Stage I: One week before the end of each month, the computer retrieves data from a meter reading file, a customer master file and an accounts file and then prints invoices. Stage II: Upon receipt of payment, payment amount and amendment to address or telephone number will be input to the computer through the keyboard and stored in a transaction file. At the end each month, the computer validates the transaction file and generates an error report. After validation, the computer uses the validated transaction file to update the customer master file and accounts file and print receipt. (a) Add flowlines to complete the following system flowchart for Stage I.
(2 marks)
(b) Label the system flowchart for Stage II with the following terms: (6 marks) customer master file, validation, receipts, payment amounts, validated transaction file, amendments, error report, updating, printing, transaction file, keying, accounts file.
(c) Explain why the transaction file and the validated transaction file should be sequential files. (2 marks) (d) Explain how the service of the gas company can be improved by storing the customer master file and the accounts file as random access files. (2 marks)
1.
(a) John writes a program to find the ranks of eleven marks. Then program accepts the marks and output them with their ranks. (Note: Ranks of marks are the positions of marks when the marks are stored in descending order, Equal marks are given equal ranks.) For explain, if the following marks are entered.
(Pascal)
However, there are several mistakes in the program. Fill in the following table to show the errors and their corrections: description of error correction
(b) Convert the following algorithm into a BASIC of Pascal program: (15 marks) 1. Declare a one-dimensional array PASSWD of integers with subscript range 1 to 50 2. Display “PLEASE ENTER THE PASSWORD” on screen 3. Initialize the array subscript variable K to 1 4. Do the following as long as K<51 Accept a character from keyboard and store it into a variable Assign ASCII of the character to PASSWDk the Kth element of PASSWD Increment K by 1 5. Initialize the integer variable PIN to be 0 6. Calculator PIN by the following formula: PIN=1*PASSWD1 + 2*PASSWD2 + 3*PASSWD3 + … + 50*PASSWD50
7. Output PIN 2. (Note: In BASIC programs, all string variable names have the suffix “$” attached.) The following subprogram converts a single character CH into string SCODE of length 4.
(a) Write down the corresponding SCODE for each CH given below: CH C E G A N D M
SCODE AABB
(6 marks) The following subprogram converts a string SPAITR of length 8 into a single character PCH.
(b) Write down the corresponding PCH for each SPAIR given below: SPAIR PCH ABAABBAB ABABBBBA
M
ABBBAAAB AABBABAB (6 marks)
The following program makes use of the above two subprograms to convert an input string IPSTRING into a shorter string SHSTRING.
(c) Write down the contents of SHSTRING when IPSTRING is “CEGAENDM” (4 marks) (d) Rewrite the input part of the program so that only strings of even length will be accepted. If the input string is not of even length, the program asks the user to reenter. (3 marks) (e) Suppose IPSTRING consists of letters ‘A’, ‘B’, …, ‘N’, ‘O’ only. Write down IPSTRING corresponding to each SHSTRING below: (6 marks) IPSTRING SHSTRING EADC QC bf AF
3.
In ABC Company, all employees have basic greater than $3000. They are also paid for working overtime. (a) Write a subprogram which accepts and validates the basic salary and the number of overtime hours. Below is a sample output of the subprogram. (7 marks) (In this output, the information following the question marks is entered through the keyboard by the user. All other items are output from the program) Enter the basic salary ? 1000 Reenter using a greater value ? 3000 Reenter using a greater value ? 20000 Enter the number of overtime hours ? –2 Reenter using a non-negative number ? 10
The overtime salary is calculated from the number of overtime hours and the basic salary according to the following rules: Rule A: The overtime salary rate is $100/hour for the first 50 hours and $60/hour for the next 50 hours. Rule B: If the number of overtime hours exceeds 100, only the first 100 hours will be paid for. The rest of the overtime hours will not be paid for. Rule C: If the calculator overtime salary is greater than the basic salary, the overtime salary will be made equal to the basic salary. (b) Write a subprogram which calculates the overtime salary from the basic salary and the number of overtime hours. (8 marks) (c) Using the subprogram in (a) and (b), write a program which accepts and validates the basic salary and the number of overtime hours, calculates the overtime salary and outputs the total salary (5 marks) (i.e. the sum of the basic salary and the overtime salary). The declarations of variables and subprograms need not be included. Below is a sample output of the program. (In this output, the information following the question marks is entered through the keyboard by the user. All other items are output fromthe program.) Enter the basic salary ? 10000 Enter the number of overtime hours ? 10 The total salary is $11000.
(d) (i)
In order to test whether the program conforms to rules A and B, a sufficiently large input value of the basic salary (such as $20000) is needed. Explain
why. (ii) With a basic salary of $20000, the values of overtime hours 20, 70 and 120 are input to test different cases of the application of rules A and B. Specify the particular cases tested. (5 marks) test data basic salary number of overtime hours 20000 20 20000 70 20000 120
4.
particular cases tested
(Note: In this question, you will awarded up to 4 marks for effective communication.) Universe Book Store is a book company with several branches. A computer system is installed at the company’s head office. The system keeps a BOOK MASTER FILE which has the following structure: Field Field Name Contents 1 REFERENCE book reference number 2 NAAME book name 3 AUTHOR author of the book 4 PUBLISHER publisher of the book 5 STOCK number of copies of the book currently stored in the head office. Branch shop assistants can order books from head office. They do this by filling in BOOK ORDER FORMs as below: Book Order Form Book reference number: Book name: Author: Publisher: Number of copies required:
Each branch shop submits the BOOK ORDER FORMs to the head office in a batch covered with a BRANCH BATCH HEADER FORM as below: Branch Batch Header Form Branch name: Branch code: Batch number: Number of order forms in the batch: The computer operator at the head office enters data from the BOOK ORDER FORMs into the computer. Data are validated by the computer as they are entered. The validated data are then stored in a TRANSACTION FILE. The computer user the TRANSACTION FILE and the BOOK MASTER FILE to produce two reports: DELIVERY NOTE and BUYING NOTE. The DELIVERY NOTE shows the names and quantities of the books to be delivered to the branches in accordance with the order forms they submitted. The BUYING NOTE shows the reference number and number of copies for each book to be bought to the head office. The stock level of each book in the head office after delivery should be maintained between 5 to 100 copies. The computer updates the BOOK MASTER FILE and then deletes the TRABSACTION FILE. (a) What is the purpose of the book reference numbers in the BOOK MASTE FILE? (2 marks) (b) If the manager of the company wants to use the BOOK MASTER FILE to analyse the demand for books and estimate profit gained, name three extra fields that have to be added to the file. (3 marks) (c) Give one advantage and one disadvantage of deleting the TRANSACTION FILE after updating. (2 marks) (d) During data validation, the computer has to check whether the data entered by the computer operator are consistent with the data stored in the BOOK MASTER FILE. Describe this checking process briefly. (2 marks) (e) Describe how the ‘branch code ’ and the number of order form in the batch’ in the BRANCH BATCH HEADER FORM can be used to reduce input errors. (6 marks) (f) Describe an algorithm for the computer produce the BUYING NOTE from the TRANSACTION FILE and BOOK MASTE FILE. (6 marks)