Answer
a) 2.7 kJ
b) 6.3 kJ
Work Step by Step
a) We must first figure out how much energy is gained by the water:
$ W = mc \Delta t \\ W = (.5kg)*(4.18)(3) = 6.3 kJ$
Because the system gains 6.3 kJ, but 9kJ of work is done, it follows that the surroundings must have gained $ 9 - 6.3 = 2.7$ kJ of energy.
b) If no energy had been lost, only the energy to increase the temperature would have been needed. This value is: $6.3$ kJ.