Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1calculateGST(price) | AA module with one job: it only works out the GST for a price and does nothing else | |
| 2assert calculateGST(100) == 10 | Btotal ← calculateGST(cartPrice) + calculateGST(deliveryFee) | |
| 3Reusing a module: the same module is called from different places instead of rewriting the code | COne module does many jobs. It should be split into smaller modules (validate, calculate, display) so each can be tested and changed alone. | |
| 4One module, one job: each module does a single task and a main program joins them together | DThe same code is copied in many places instead of being placed in one reusable module that is called when needed. | |
| 5define doEverything() read input check input calculate total print receipt | EvalidateInput() processOrder() showReceipt() | |
| 6price ← price * 1.1 ... same line copied into 6 places | FA test that checks one module on its own, without running the rest of the program |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
module — A self-contained part of a program that does one job, so it can be built, tested on its own, reused in other places and changed without breaking the rest of the solution.define calculateTotal(price, qty)
return price * qtydefine addGST(price)
return price * 1.1total1 ← calculateTotal(5, 2)
total2 ← calculateTotal(8, 3)if addGST(100) = 110 then
print "Test passed"
end ifmarks ← getMarks()
avg ← calculateAverage(marks)
print avg