Loading...
Loading...
Loading...
A ride app charges per km: a cab Rs. 12, a bike Rs. 6, an auto Rs. 25 plus Rs. 15 a km. Every ride also pays Rs. 2 for each minute of waiting. Write Ride with long fare(long km) and an overload long fare(long km, long wait) that adds the waiting charge to fare(km). Children override only fare(long km).
CAB, BIKE or AUTO), the km and the waiting minutes.<TYPE> Rs. <fare> for each ride, then Total Rs. <sum>.Example
Input
3 CAB 10 5 BIKE 10 0 AUTO 4 3
Output
CAB Rs. 130 BIKE Rs. 60 AUTO Rs. 91 Total Rs. 281
Auto: 25 + 4 × 15 + 3 × 2 = 91.
Try the problem first. Open one hint at a time.
The two-argument fare is written once in Ride and calls fare(km) on the current object.
So a bike ride uses the bike's per-km rule inside the inherited two-argument method.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor