The area of a rectangular floor (in square centimetres) is calculated using the following formula:
area (in cm2)=length×width \text{area (in cm}^2\text{)} = \text{length} \times \text{width} area (in cm2)=length×widthTo convert this area to square metres (m2\text{m}^2m2), the area in cm2\text{cm}^2cm2 is divided by 10 00010\,00010000.
The total cost of carpeting is then found by multiplying this area in m2\text{m}^2m2 by the price per square metre.
The algorithm below is designed to output the total carpet cost for a room with a length of 500 cm, a width of 400 cm, and a carpet price of £25 per square metre.
A subroutine called calcCarpetCost has been developed as part of the algorithm.
Complete the program by identifying the correct term from the pool of options to fill each of the six empty gaps.
lengthwidthpricePerSqMetreareaSqCmareaSqMetresareaSqCm / 10000areaSqCm * 10000areaSqCm MOD 10000RETURNSUBROUTINEOUTPUTcalcCarpetCostcalcCarpetArea500SUBROUTINE calcCarpetCost([Gap 1], width, [Gap 2])
[Gap 3] ← length * width
areaSqMetres ← [Gap 4]
totalCost ← areaSqMetres * pricePerSqMetre
[Gap 5] totalCost
ENDSUBROUTINE
OUTPUT [Gap 6](500, 400, 25)
131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.