Loading...
Loading...
Loading...
A courier charges Rs. 8 a km for standard delivery. Express is the standard charge plus Rs. 50. Night delivery is an express delivery that adds 20% of the express charge, rounded down. Build Delivery → Express → Night, where each class extends the one above with super.charge(km).
STD, EXPRESS or NIGHT) and the distance in km.<TYPE> Rs. <charge> for each parcel.Example
Input
3 STD 10 EXPRESS 10 NIGHT 10
Output
STD Rs. 80 EXPRESS Rs. 130 NIGHT Rs. 156
Night: 130 + 130 × 20 / 100 = 156.
Try the problem first. Open one hint at a time.
Night extends Express, and Express extends Delivery.
In Night: long total = super.charge(km); return total + total * 20 / 100;.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor