question 84 Functions · easy
Car park fee
A shopping-centre car park charges by the length of the stay. Stays of up to 30 minutes are free. Longer stays pay 2.50 for every started hour of the whole stay, so 61 minutes is two hours. No stay costs more than the daily maximum of 18.00.
Function
parking_fee(minutes)minutesa whole number, 0 or more
Returns0 for up to 30 minutes; otherwise 2.50 × started hours, but never more than 18.00
Examples
callparking_fee(95)returns5.0
callparking_fee(20)returns0
callparking_fee(45)returns2.5