Past-paper question · 2019 October-November · Paper 23 · Q6(b)

Question 6(b) 2019 · October-November · Paper 23 · 7 marks

Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Original past-paper question for 6(B)
Reveal official mark-scheme answer Official mark-scheme answer for 6(B)

Official answer for Question 6

Part (b)

✓
PROCEDURE DisplayResults(Author:STRING, Count:INTEGER)

Question 7

✓
DECLARE Index, GLen : INTEGER
✓
DECLARE Gap : STRING
✓
Gap ← "
✓
" // 25 spaces
✓
IF Count = 0
✓
THEN
✓
OUTPUT "Search found no books by: " & Author
✓
ELSE
✓
OUTPUT "Books written by: " & Author
✓
OUTPUT "Title" & LEFT(Gap, 20) & "Location"
✓
FOR Index ← 1 TO Count
✓
GLen ← 25 – LENGTH(Result[Index, 0])
✓
OUTPUT Result[Index, 0] & LEFT(Gap, GLen) &
✓
Result[Index, 1]
✓
ENDFOR
✓
OUTPUT "Number of titles found: " &
✓
NUM_TO_STRING(Count)
✓
ENDIF
✓
ENDPROCEDURE
✓
One mark for each of the following (max 7):

Mark scheme 9608_w19_ms_23.pdf →

Show text version of question

Question 6

Part (b)

Question 6

A text file, Library.txt, stores information relating to a book collection. The file stores four

pieces of information about each book on separate lines of the file, as follows:

Line n: <Book Title> Line n + 1: <Author Name> Line n + 2: <ISBN> Line n + 3: <Location>

Information is stored as data strings.

Information relating to two books is shown:

File line Data 100 "Learning Python"

101 "Brian Smith"

103 "BD345"

104 "Surviving in the mountains"

105 "C T Snow"

107 "ZX001"

Part (b)

The function FindBooksBy() has already been called and has stored values in the array

Result.

The procedure, DisplayResults(), will output the information from the array.

The procedure receives the following two parameters:

  • a string containing the author name
  • an integer value representing the number of books found

The output should be formatted as in the following example:

Books written by: Brian Smith

Title Location Learning Python BD345 Arrays are not lists CZ562 Learning Java CZ589

Number of titles found: 3

If no books by the author are found, the following should be output:

Search found no books by: Brian Smith

Question 15

Write pseudocode for the procedure DisplayResults().

Refer to the Appendix on page 16 for the list of built-in functions and operators.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

[7]

Question 16

Appendix Built-in functions (pseudocode) Each function returns an error if the function call is not properly formed.

MID(ThisString : STRING, x : INTEGER, y : INTEGER) RETURNS STRING returns a string of length y starting at position x from ThisString Example: MID("ABCDEFGH", 2, 3) returns "BCD"

LENGTH(ThisString : STRING) RETURNS INTEGER returns the integer value representing the length of ThisString Example: LENGTH("Happy Days") returns 10

LEFT(ThisString : STRING, x : INTEGER) RETURNS STRING returns leftmost x characters from ThisString Example: LEFT("ABCDEFGH", 3) returns "ABC"

RIGHT(ThisString: STRING, x : INTEGER) RETURNS STRING returns rightmost x characters from ThisString Example: RIGHT("ABCDEFGH", 3) returns "FGH"

INT(x : REAL) RETURNS INTEGER returns the integer part of x Example: INT(27.5415) returns 27

ASC(ThisChar : CHAR) RETURNS INTEGER returns the ASCII value of ThisChar Example: ASC('A') returns 65

MOD(ThisNum : INTEGER, ThisDiv : INTEGER) RETURNS INTEGER returns the integer value representing the remainder when ThisNum is divided by ThisDiv Example: MOD(10,3) returns 1

Operators (pseudocode)

Operator Description Concatenates (joins) two strings & Example: "Summer" & " " & "Pudding" produces "Summer Pudding" Performs a logical AND on two Boolean values AND Example: TRUE AND FALSE produces FALSE Performs a logical OR on two Boolean values OR Example: TRUE OR FALSE produces TRUE

Topic relevance

Why this question appears here

99% assigned-topic match · Data types and structures › Data types and records

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_w19_qp_23.pdf

Keep practising this topic