|
|||||||
|
|
|
|||||
|
|
|||||||
December 1999 SECTION B [60 Marks] |
Click here to access other
sections Section A Front Cover SUGGESTED SOLUTIONS |
|
Answer any TWO questions in this section
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1. | a) A program is to be developed
to read in a collection of exam scores ranging in value from 0 to 100.
Range validation is to be carried out on the exam scores entered. If
a score is not within the permissible range, an error message is to
be displayed and the user should be allowed to re-enter the score.
Your program should count the number of outstanding scores (90-100), the number of satisfactory scores (60-89), the number of unsatisfactory scores (1-59), and the number of zero scores. At the end of the run, your program should display the number of students in each category (i.e. outstanding, satisfactory, unsatisfactory, and zero) and the average exam score. An outline of a program flowchart is given on the next page, with some conditions and actions omitted. The program variables names to be used are: score, outstd, sat, unsat, zero, count, sum and average Your task is to 'fill in' the gaps: i) Draw the boxes and actions for initialisation, to replace dotted box (i). [2]
ii) State the condition for selection box (ii). Note carefully which way round the 'yes' and 'no' branches are. [1] more exams scores to enter? iii) State the action for box (iii). [1] ave = sum/count iv) Draw the box for the final output, to replace dotted box (iv). [2]
[1 mark for display shape, 1 mark for all necessary outputs; max 2 marks] v) State the condition for selection box (v). [1] (score < 0) or (score > 100) vi) State the condition for selection box (vi) [1] score = 0 vii) State the condition for selection box (vii) [1] score <= 59 viii) State the condition for selection box (viii). [1] score <= 89 ix) State the action for box (ix). [1] outstd = outstd + 1 x) Draw the boxes and actions, to replace dotted box (x). [2]
[boxes can appear in either order, or combined]
i) User request / User requirement / Statement of problem
[any one] [1] c) i) Briefly explain what is meant by structured programming. [2] A program is broken down into smaller components(modules)
[1] ii) State five advantages of using structured programming. [5] Modules can be reused [to save development time] [1]
|
[30] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2. |
a) A sample screen design for the main menu of a program is as follows:
The main menu will be displayed again after selection of each choice if users do not select choice 4. In choice 1, the user is prompted for a collection of records and the records will then be stored in a file. In choice 2, all the records from the file will be retrieved and displayed on the screen. In choice 3, the user is prompted to enter a target key field. All of the records which match the target will be displayed as the program will retrieve one record from the file at a time, and compare it with the target key field. If it matches, the record is displayed. If it does not match, the next record is retrieved and so on until the end of file. In choice 4, the user is able to end the program. Using a CASE_ENDCASE construct, express the program logic using Pseudocode. (Note: Do not use IF_THEN_ELSE_ENDIF construct to process the menu choices) [13]
1. For using "REPEAT_UNTIL choice=4" to express
the whole program logic [Accept also "DO_WHILE choice<>4"
, "WHILE choice<>4 2. For having at least one DO_ENDDO as the starting statement inside either one of the choices [1] 3. For getting input of choice before CASE choice [1] 4. For putting CASE_ENDCASE in the correct place [1] 5. For at least one choice stated inside CASE_ENDCASE [1] 6. For expressing the correct logic using a loop in
choice 1 7. For expressing the correct logic using a loop in
choice 2 8. For getting input of target key field before starting the loop in choice 3 [1] 9. For using IF construct for comparison with target key field in choice 3 [1] 10. For expressing the correct logic using a loop in
choice 3 11. For good indentation [1] 12. Show key words in capital letters [1] 13. For expressing the correct logic for the entire program [Ignore pseudocode syntax error] [1] [If candidates use IF_THEN_ELSE_ENDIF, award mark based on points 1,6,7,8, 9,10,11 ie. maximum 7 marks to be awarded]
Recursive module is a module that calls itself [1] Each time it calls itself, it operates on different parameters [1] ii) State three essential components of a recursive module. [3] [Terminating] condition/stopping case [1] iii) State one advantage and one disadvantage of using recursion as compared to iteration. [2] Advantage: Specify a natural, simpler solution to solve
an iterative problem [1] c) Name and briefly describe five types of data processing files. (Do not give examples) [10] Master file [1] [Any five of the above types, one mark for name, one mark for description, maximum 10 marks]
|
[30] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3. | a) Consider the following
program:
Step no. Dry run the above code showing, at each step, the content of the variables i, j, k and the other expressions involving i, j and k. Take care to show the execution of each numbered statement. [13]
Award one mark for every two correct row entries [12] [NB: care need with marking: if an error is made, it should be penalised only once. Subsequent rows should be marked, based on the error row. Thus an answer which has just the first row above wrong, and then all subsequent rows 'correct' based on the erroneous row, would get 1 (for headings) + 11 (for rows) marks, even though all the rows might be different from the totally correct solution above.] b) There are three kinds of loop-control statements often found in programming languages: for, while and repeat-until. i) When would you use the for loop construct? [1] When you know the number of iterations [before loop execution] [1] ii) State the differences between a repeat-until loop and a while loop, in terms of : · execution of the loop body [2 The loop body of repeat-until loop will always execute
at least once [1]
Loop body in repeat-until is repeated until its loop-termination
condition becomes true [1] c) i) Give short descriptions of the following types of decision table : · Limited entry decision table [2] Limited entry: · Extended entry decision table [3] Extended entry: · Mixed entry decision table [2] Mixed entry: ii) Write brief notes to explain the purpose of a decision table preprocessor. [3] It is a software design tool (program development aid)
[1] d) State the two types of high level language translator. [2] Interpreter [1] |
[30] |