Loading...
Loading...
Loading...
A smart meter knows each appliance's power: a fan 75 W, a light 10 W, an AC 1500 W. An inverter AC is an AC that uses only 60% of a normal AC's energy. Energy in watt-hours is watts × hours. Write Appliance with String name() and long energy(long hours); InverterAc extends Ac reuses super.energy(hours).
FAN, LIGHT, AC or INVERTER_AC) and the hours it ran.<TYPE> <Wh> for each appliance, then Total <Wh>, then Biggest <TYPE> (the first one listed on a tie).Example
Input
4 FAN 10 LIGHT 6 AC 4 INVERTER_AC 5
Output
FAN 750 LIGHT 60 AC 6000 INVERTER_AC 4500 Total 11310 Biggest AC
Inverter AC: 1500 × 5 = 7500, times 60% = 4500.
Try the problem first. Open one hint at a time.
A default watts() in the parent plus overrides is fine too; what matters is that each class answers for itself.
InverterAc.energy: return super.energy(hours) * 60 / 100;.
Write your Java code, run it on the examples and submit it to hidden tests.
Solve in the editor