Heating 1 kg of water by 1 °C takes 4184 joules. HeatWater reads the mass of water in kg, its starting temperature and the final temperature, and prints the energy needed in joules, in kilojoules and in kilowatt-hours (1 kWh = 3 600 000 J).
Use final double constants for 4184 and 3 600 000. For the input
55.5 3.5 10.5
the program prints
Energy: 1625484.0 J
Energy: 1625.5 kJ
Energy: 0.452 kWh