From first law of thermodynamics, we have
U = q + w For state A to B : q = +5 J, w = 8 J and
UAB = 5 + (8) = 3 J For state B to A : q = 3 J Since the internal energy is a state function, we have
UBA =
UAB. Therefore,
UBA = q + w 3 = 3 + w w = 6 J Positive value of work indicates that 6 J of work is done by the surrounding on gas.