IEB 2023: Parking Ticket System

HardGrade 12

RentMyParking is testing a paperless parking ticket system. A vehicle can use DAILY parking (must exit before midnight the same day it entered, or the owner is fined) or LONG-TERM parking (assigned to a permanent bay, billed per day). You need to model both with an inheritance hierarchy, read a batch of parking records, sort them by registration number, and print each one's fee. Daily parking costs R24.50 per hour the vehicle is parked, using the whole number of hours between entry and exit (ignore any leftover minutes). If the vehicle stays past midnight into the next day, it is fined a flat R850.00 instead. Long-term parking costs R250.00 per whole day parked (partial days under 24 hours cost R0.00). See the 📄 Exam Paper tab for the verbatim question. Platform note: the original exam reads this data from a file called parkings.txt — here it comes from standard input instead, in the same line format.

Input / Output

Input: Line 1: an integer N — the number of parking records. Next N lines, one record each, semicolon-separated: Daily: <registration>;<entry yyyy/MM/dd HH:mm>;<exit yyyy/MM/dd HH:mm> Long-term: <registration>;<entry yyyy/MM/dd HH:mm>;<exit yyyy/MM/dd HH:mm>;<parking bay> (a record is long-term if — and only if — it has that trailing parking-bay field) Output: each record's details, sorted alphabetically by registration number, in this exact format: Registration: <reg> Fee: R<fee> Entry: <entry> Exit: <exit> [Parking Bay: <bay> -- long-term only] with one BLANK LINE between records (none after the last one). Fee must print exactly as a Java double converts to a string (e.g. R850.0, R122.5, R1000.0 — never trailing zeros beyond one decimal place, no rounding).

Examples

Input

2
AAA 111 GP;2023/01/01 08:00;2023/01/01 14:00
BBB 222 GP;2023/01/01 08:00;2023/01/05 08:00;A1

Expected Output

Registration: AAA 111 GP Fee: R147.0
Entry: 2023/01/01 08:00 Exit: 2023/01/01 14:00

Registration: BBB 222 GP Fee: R1000.0
Entry: 2023/01/01 08:00 Exit: 2023/01/05 08:00
Parking Bay: A1

+ 2 hidden tests checked on Submit.

Files

Main.java is the entry point. Add extra classes for OOP exercises — they compile together.

Daily.java
Loading...

Run your code to see test results here.