0% found this document useful (0 votes)
41 views22 pages

Structure Charts for Modular Programming

The document discusses the structure chart in modular program design, detailing the relationships between various program modules and the parameters they exchange. It includes examples of modules for tasks such as updating passwords, car rentals, and library loans, as well as exercises for drawing structure charts and identifying features of modular design. Additionally, it emphasizes the importance of decomposition in programming and provides pseudocode headers for various modules.

Uploaded by

faza72350
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views22 pages

Structure Charts for Modular Programming

The document discusses the structure chart in modular program design, detailing the relationships between various program modules and the parameters they exchange. It includes examples of modules for tasks such as updating passwords, car rentals, and library loans, as well as exercises for drawing structure charts and identifying features of modular design. Additionally, it emphasizes the importance of decomposition in programming and provides pseudocode headers for various modules.

Uploaded by

faza72350
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Page | 4

12.2 Structure Chart


Test Yourself 10C Winter 19 P23
3 Three program modules process updating of passwords in a file. A description of
the relationship between the modules is summarised as follows:

Module name Description


• Takes two parameters: AccountID and OldPassword
GetPassword()
• Returns a string containing the new password
• Takes two parameters: AccountID and NewPassword
UpdateFile() • Returns a Boolean value to indicate whether or not the
update was successful
• Calls GetPassword() to obtain the new password then
ChangePassword()
calls UpdateFile() to write the new password to the file

Draw a structure chart to show the relationship between the three modules and the
parameters passed between them. [5]

Winter 19 P21
2 (a) A structure chart is often used in modular program design. One feature shown is the
sequence of module execution.
State four other features that may be shown.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
Feature 3 ..................................................................................................................................
...................................................................................................................................................
Feature 4 ..................................................................................................................................
.............................................................................................................................................. [4]
Page | 5
Worked Example
3 A modular program design consists of four modules:
Module1() has three sub-tasks. Each sub-task is implemented by a single subroutine (either a
function or a procedure).
The subroutine headings are defined as follows:
FUNCTION Module2 (Weight : REAL) RETURNS BOOLEAN
PROCEDURE Module3 (Weight : REAL, Customer : STRING, Purchased : DATE)
FUNCTION Module4 (Purchased : DATE, Account : INTEGER) RETURNS INTEGER
(a) State the term given to values passed between Value Label
modules. Boolean return value A
Integer return value B
........................................................................................[1]
Account C
(b) Draw a structure chart to represent the program Customer D
design. Purchased E
Weight F
Use the letters in the table to label the values passed
between modules.
Page | 6
Selection Statements in Structure Chart
The diamond shape shows a condition that is either True or False. So either one branch or the other
will be followed.
Page | 7
11a 9608 S20 P21
2 (a) Three modules form part of a program for a car rental company. A description of the
relationship between the modules is summarised as follows:
Module name Description
A customer will pay for each car rental either by bank card or by using
RentCar()
their account with the rental company.
Called with parameter HireCost, representing the cost of the rental.
PayByCard() Returns a BOOLEAN value to indicate whether or not the card payment
was successful.
Called with parameters HireCost, AccountNumber, CurrentBalance and
AccountLimit.
• Checks whether HireCost plus the CurrentBalance would exceed
PayByAccount() the AccountLimit. If so, then the rental is not authorised.
• If the rental is authorised, then the CurrentBalance is updated.
• Returns a BOOLEAN value to indicate whether or not the rental was
authorised.

Draw a structure chart to show the relationship between the three modules and the
parameters passed between them. [5]
Page | 8
Repetition in Structure Chart
Figure shows the structure chart for the pyramid-drawing program. The semi-circular arrow
represents repetition of the modules below the arrow. The label shows the condition when
repetition occurs.

Draw a structure chart for the following problem: A user attempts to log on with a user ID.
User IDs and passwords are stored in two 1D arrays (lists). The algorithm searches the list of
user IDs and looks up the password in the password list. The user is given three chances to
input the correct password. if the correct password is entered, a suitable message is output. If
the third attempt is incorrect, a warning message is output.
Page | 9
Page | 10
1ac 9618 S21 P21
2 (a) Four program modules form part of a program for a library.
A description of the relationship between the modules is summarised as follows:
Module name Description
UpdateLoan() • Calls either LoanExtend() or LoanReturn()
• Called with parameters LoanID and BookID
• Calls CheckReserve() to see whether the book has been reserved for
LoanExtend()
another library user
• Returns TRUE if the loan has been extended, otherwise returns FALSE
• Called with BookID
CheckReserve()
• Returns TRUE if the book has been reserved, otherwise returns FALSE
• Called with parameters LoanID and BookID
LoanReturn() • Returns a REAL (which is the value of the fine to be paid in the case of an
overdue loan)
Draw a structure chart to show the relationship between the four modules and the parameters
passed between them. [5]

(b) The definition for module LoanReturn() is amended as follows:


Module name Description
Called with parameters LoanID, BookID and Fine
LoanReturn() The module code checks whether the book has been returned on time
and then assigns a new value to Fine
• LoanID and BookID are of type STRING
• Fine is of type REAL
Write the pseudocode header for the amended module LoanReturn().
.....................................................................................................................................................
........................................................................................................................................... [2]
Page | 11
3b 9618 s22p22 - 3 (a) The module headers for five modules in a program are defined in
pseudocode as fol
Pseudocode module header
FUNCTION Mod_V(S2 : INTEGER) RETURNS BOOLEAN
PROCEDURE Mod_W(P4 : INTEGER)
PROCEDURE Mod_X(T4 : INTEGER, BYREF P3 : REAL)
PROCEDURE Mod_Y(W3 : REAL, Z8 : INTEGER)
FUNCTION Mod_Z(F3 : REAL) RETURNS INTEGER
An additional module Head() repeatedly calls three of the modules in sequence.
A structure chart has been partially completed.
(i) Complete the structure chart to include the information given about the six modules.
Do not label the parameters and do not write the module names. [3]

(ii) Complete the table using the information in part 3(a) by writing each module name to
replace the labels A to F. [3]
Label Module name
A
B
C
D
E
F
Page | 12
(b) The structure chart represents part of a complex problem. The process of decomposition
is used to break down the complex problem into sub-problems.
Describe three benefits of this approach.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
............................................................................................................................................. [3]
3c 9618 S22 P23
3 Four program modules are defined as follows:
Pseudocode module header
PROCEDURE Sub1_A(XT : INTEGER, PB : STRING)
FUNCTION Sub1_B(RA : INTEGER) RETURNS BOOLEAN
PROCEDURE Sub1_C(SB : INTEGER, BYREF SA : STRING)
PROCEDURE Section_1()
(a) A structure chart will be produced as part of the development process.
Describe the purpose of a structure chart.
.....................................................................................................................................................
.....................................................................................................................................................
.....................................................................................................................................................
.......................................................................................................................................[2]
(b) Module Section_1() calls one of the other three modules. The module called will be
selected when the program runs.
Draw the structure chart. [5]
Page | 13
Test Yourself To code the ‘Search by product code’ procedure, Ahmed wants to draw a
structure chart showing the different stages. The variables used are shown in the identifier
table.
Identifier Data type Description
SearchCode STRING Product code input by the user
Details STRING Product description found

The main module has three sub modules. You can assume that before the procedure is run,
all the product data is read from file PRODUCTS.
Draw structure chart to show modular design. [4]
FUCNTION InputSearchCode( ) RETURNS STRING
FUCNTION SearchDetails(SearchCode : STRING ) RETURNS STRING
PROCEDURE OutputDetails (SearchCode: STRING, Details: STRING )
Page | 14
Test Yourself Summer 2019 P22
3 The following structure chart shows the relationship between three modules.

Parameters A to E have the following data types:


A, D : STRING
C : CHAR
B, E : INTEGER
(a) (i) Write the pseudocode header for module SubA(). [3]

(ii) Write the pseudocode header for module SubB(). [3]

(b) Module hierarchy and parameters are two features that may be represented on a structure
chart.
State two other features than can be represented.
Feature 1 ..................................................................................................................................
Feature 2 ................................................................................................................................ [2]
Page | 15
Test Yourself 10b Winter 19 P22
5 The module headers for three modules in a program are defined in pseudocode as follows:
Pseudocode module header
PROCEDURE Lookup(P4 : INTEGER, BYREF M4 : STRING)
FUNCTION Update(T4 : INTEGER) RETURNS INTEGER
FUNCTION Validate(S2:INTEGER, P3:STRING) RETURNS BOOLEAN
A fourth module, Renew(), calls the three modules in the following sequence.
Validate()
Lookup()
Update()
Draw a structure chart to show the relationship between the four modules and the parameters
passed between them. [7]
Page | 16
Test Yourself Summer 2015 Paper 23
3 A flooring company provides for each customer an estimated price for a new job. Each job
is given a Job ID. The job cost is calculated from the length (nearest metre) and width
(nearest metre) of the room. The process for calculating the price is as follows:
 the floor area is calculated with 18% added to allow for wastage
 the job cost is calculated at $50 per square metre
The structure chart shows the modular design for a program to produce a new job cost.

(i) Give the data items corresponding to the labels A to E in the structure chart.
A ....................................................................... B ...........................................................
C ....................................................................... D ............................................................
E .................................................................................................................................... [5]
(ii) The procedure below is one of the modules shown on the structure chart.
Parameters can be passed ‘by value’ or ‘by reference’.
Complete the procedure header below showing for each parameter:
• its parameter passing mechanism • its identifier • its data type
PROCEDURE CalculateJobCost( ....................................................................................... )
JobCost(Length * Width * 1.18) * 50
ENDPROCEDURE [5]
Page | 17
Software Development Topical Past Papers from SoW
0 9618 Specimen Paper 2 - SoW
2 Roberta downloads music from an online music store. The diagram shows part of a
structure chart for the online music store program.

(a) State three items of information that the diagram shows about the design of the program.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
...................................................................................................................................................
3 ................................................................................................................................................
.............................................................................................................................................. [3]
(b) Examples of the data items that correspond to the arrows are given in the table.
Arrow Data item
A 234.56
B "Ms Roberta Smith"
C TRUE
Use pseudocode to write the function header for the Card payment module.
...................................................................................................................................................
.............................................................................................................................................. [3]
Page | 18
9608 S16 P21-22 - SoW
4 (a) Structured programming involves the breaking down of a problem into modules.
Give two reasons why this is done.
1 ................................................................................................................................................
...................................................................................................................................................
2 ................................................................................................................................................
............................................................................................................................................. [2]
(b) A team needs to write a program to implement an online shopping system. Customers will
access the program via a website.
Customers can search for items before adding them to a virtual shopping basket. When they
have finished shopping, they pay for the items. The program provides output for the dispatch
of the items. Some of the key features of the system are as follows:
(a) a customer can add many items to the shopping basket
(b) payment may be either by credit or debit card, or by adding to a customer account
(c) the shop may dispatch the items in one or more packages
The structure chart below shows the program modules only.
(i) Draw on the chart, the symbols that represent the key features listed in part (b) above.[3]
Page | 19
(ii) A section of the chart in part (b)(i) is shown below. It is to show the parameters passed
between the Checkout and Card payment modules.

Name the three data items corresponding to the arrows.


[3]
Arrow Data item
A
B
C

7a 9608/21 Jun 18 Q4b


4 (a) A structure chart is used in modular program design.
Iteration and selection are two features of an algorithm that may be shown on a structure
chart. Give three other features.
Feature 1 ..................................................................................................................................
...................................................................................................................................................
Feature 2 ..................................................................................................................................
...................................................................................................................................................
Feature 3 ..................................................................................................................................
.............................................................................................................................................. [3]
Page | 20
(b) Pseudocode for a function is shown.
FUNCTION ItemProcess (AddItem, InString : STRING) RETURNS BOOLEAN
DECLARE RetFlag : BOOLEAN
RetFlag  FALSE
IF AddItem = "Yes"
THEN
RetFlag  AddToList (InString)
ELSE
CALL RemoveFromList(InString)
ENDIF
RETURN RetFlag
ENDFUNCTION
Draw a structure chart on the next page to represent this pseudocode.
Page | 21
3b 9618 s22p22 - 3
Page | 22
Examiner Report Question 3
(a) (i) This question proved very challenging for most candidates.
Some candidates gained credit for the two parameters. Many candidates added labels to the existing
parameters, despite the question directing them otherwise.
(ii) Many correct answers were seen, suggesting that candidates were able to map the module
headers to the original diagram.
(b) Many candidates gained marks for 'easier to...' answers relating either to the problem or the
implementation of a solution. The ability to assign problems to different teams was also commonly
seen.
Many answers were vague and did not relate sufficiently to the problem or to the sub-problems.
Candidates should familiarise themselves with the meaning of the command words used in the
questions and form their answers accordingly.
A small number of candidates gave benefits of structure charts, rather than benefits of decomposition.
Use of vague terminology was commonplace, for example, 'it makes testing more convenient'.
3c 9618 S22 P23

Examiner Report Question 3


Page | 23
(a) Many fully correct answers were seen, usually quoting the relationship between modules and the
parameters that passed between them.
(b) This part was well-answered by the majority of candidates, with nearly all diagrams being
recognisable as structure charts.
Common mistakes were the omission of the decision diamond and treating the ByRef
parameter as a separate parameter plus a separate return value.
A very small number of candidates gave no answer or provided a diagram that was more akin to a
program flowchart.
Test Yourself 10b Winter 19 P22

Test Yourself Summer 2015 Paper 23


Page | 24

0 9618 Specimen Paper 2 - SoW

9608 S16 P21-22 - SoW


Page | 25
7a 9608/21 Jun 18 Q4b

Examiner Comments
(a) A minority of candidates provided correct responses for this part. It was evident from the
quality of responses that candidates were unfamiliar with a structure chart.

Candidates often stated inputs and outputs as features shown on a structure chart. These are
not a feature of a structure chart and it appeared that some candidates were mistaking a
program flowchart for a structure chart.

(b) A significant number of candidates did not attempt this question. As with the previous
question, candidates were not aware of how to draw a structure chart. The majority of
candidates who attempted this question, made an attempt to draw another program
flowchart which gained no credit. A minority of candidates were aware of the arrows used in
a structure chart to show the direction of parameters but applied them incorrectly.

You might also like