T4 Homework 4
T4 Homework 4
The following program asks the user to enter dimensions of a package they wish to send. If the
volume of the package is greater than 2.5 m3 or any side of the package is greater than 1 metre,
the package won’t be accepted.
INPUT a
INPUT b
INPUT c
d a * b * c
(a) The identifiers that have been used are not meaningful. Replace each identifier
in the table below with a more meaningful one. [4]
(b) Add two comments to the code above that would make the program more
maintainable by explaining what more complicated lines of code do. [2]
1
Homework 4 Maintainable programs
Unit 10 Advanced programming and databases
(c) The code would be more maintainbable if it made use of a function to calculate if a package
was accepted or not. This function would return TRUE if the package was an acceptable
size and FALSE if not.
Rewrite the code to make use of a function. The new program should use meaningful
identifiers, however, you do not need to add comments to it. [6]
[Total 12 marks]