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.
Practise OCR GCSE Computer Science Programming fundamentals with exam-style questions for GCSE Computer Science. 100 questions, matched to the OCR GCSE Computer Science (J277) specification and written in Component 01 and Component 02 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.