# solution

(f) Award marks as follows up to [5 max].
Award [1] for calculating excess dates (XD) (as a step only – no precise code required). Award [1] for a correct calculation of payment due for fines lasting more than one day, upon test. Award [1] calculating parking duration (DRN) within the same day (as a step only, no precise code required). Award [1] for correct calculation of payment due for parking duration lasting less than 2 hours (within the same day) (CASE 1 and CASE 2). Award [1] for correct calculation of payment due for parking duration lasting more than 2 and less than 4 hours (within the same day) (CASE 3 and CASE 4). Award [1] for correct calculation of payment due for parking duration lasting more than 4 hours (within the same day).

For example:

Compute excess dates (XD), using arrival date (AD) and current date (CD) (eg XD = CD–AD);

If XD ≠ 0 then PAY= XD*RULES[1][2] (accept PAY = XD*30) (ie if the dates are not the same, the amount to pay is the maximum fine for XD days);

Else compute parking duration (DRN), using arrival time (AT) and current time (CT) (eg DRN = CT–AT);

After suitable transformation into minutes;

Case (1): DRN =< 30 then PAY = RULES [0][0] (accept 0.50 EUR) Case (2): 30<DRN=<120 then PAY = RULES [0][1] (accept 3.00 EUR) Case (3): 120<DRN=<150 then PAY = RULES [0][1] + RULES [1][0] (accept 3+5 = 8 EUR) Case (4): 150<DRN=<240 then PAY= RULES [0][1] + RULES [1][1] (accept 3+15= 18 EUR) Case (5): 240<DRN then PAY = RULES [1][2] (accept 30 EUR) [5]
Notes: Other solutions are possible, award marks accordingly. It is not necessary to refer to RULES (and relative notation) as a double array. Accept constructions with flowcharts or pseudocode. Accept calculations that make use of div and mod, provided they are correct and respect the specification of a daily-based fee system. Accept DRN presented in hours. Award marks for logic, not for the syntax

Scroll to Top