Loading...
Loading...
Loading...
A mall parking lot charges by vehicle type, per started hour (61 minutes is 2 hours; 0 minutes still counts as 1 hour). enum VehicleType has a private final code and abstract int charge(int hours):
BIKE('B'): Rs. 20 per hour.CAR('C'): Rs. 50 per hour for the first 3 hours, then Rs. 30 per hour.BUS('U'): Rs. 100 per hour, but at least Rs. 200.For every exit, print the charge; then a summary per type in the enum's order and the total collected.
NUMBER TYPE h h: Rs. charge, or NUMBER: unknown type X. Then one line per type, TYPE: count n, Rs. amount, then Total: Rs. total.Example
Input
4 KA01AB1234 C 290 TN09CD5678 B 180 MH12EF9012 U 45 DL03GH3456 X 30
Output
KA01AB1234 CAR 5 h: Rs. 210 TN09CD5678 BIKE 3 h: Rs. 60 MH12EF9012 BUS 1 h: Rs. 200 DL03GH3456: unknown type X BIKE: count 1, Rs. 60 CAR: count 1, Rs. 210 BUS: count 1, Rs. 200 Total: Rs. 470
290 minutes start 5 hours: 3 × 50 + 2 × 30 = 210.
Try the problem first. Open one hint at a time.
Hours: Math.max(1, (minutes + 59) / 60).
Read the code with sc.next().charAt(0) and look it up with a static fromCode(char c).
Keep two arrays, count and amount, indexed by ordinal() for the summary.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor