A 3D printing bureau calculates the total cost of a print run by multiplying the duration of the print job in hours by a rate of £6.80 per hour, and then adding a flat setup fee of £12.50.
A program is written to allow a technician to enter the print duration in hours as a whole number between 2 and 24, then calculate and output the total cost.
01 h = 0
02 cost = 0.0
03 h = input("Enter print hours")
04 if h < 2 OR h > 24 then
05 print("Error: duration out of range")
06 else
07 cost = (h * 6.80) + 12.50
08 print(cost)
09 endif
Explain, using examples from the program, two ways to improve the maintainability of the program.
95 exam-style questions on OCR GCSE Computer Science Programming fundamentals. Each one has a worked solution and a mark scheme showing where the marks go.