Answer
$38.4\;\rm J$
Work Step by Step
We are given the following,
$$P_1=\dfrac{F_{sp}}{A}=\dfrac{kx_1}{A}$$
where $x$ is the compressed distance by the spring and $A$ is the cross-sectional area of the piston.
Hence, the final pressure is given by
$$P_2 =\dfrac{kx_2}{A}$$
$$V_1=AL_1$$
and $$V_2=AL_2=A(L_1+\Delta L)$$
$$T_1=300\;\rm K$$
so the final temperature is given by
$$\dfrac{P_1V_1}{T_1}=\dfrac{P_2V_2}{T_2}$$
Hence,
$$T_2=\dfrac{P_2V_2T_1}{P_1V_1} $$
Plugging from the given;
$$T_2=\dfrac{ (\frac{kx_2}{A})(AL_2)(300)}{(\frac{kx_1}{A})(AL_1)} =\dfrac{x_2L_2(300)}{x_1L_1} $$
where $x_1=2$ cm and after expanding the gas extra 6 cm, the spring will be compressed a distance of $x_2=6+2=8$ cm.
$$T_2=\dfrac{ ( 0.08)( 0.16)(300)}{( 0.02)( 0.10)}=\bf 1920\;\rm K $$
Now we can find the change in the thermal energy of the system
$$\Delta E_{th}=Q+W=nC_{\rm v}\Delta T$$
Hence, the heat energy needed is given by
$$Q=nC_{\rm v}(T_2-T_1)-W\tag 1$$
Now we need to find the work done on the gas and the number of moles of the gas.
$$n=\dfrac{P_1V_1}{RT_1}$$
Plugging the known;
$$n=\dfrac{(\frac{kx_1}{A})(AL_1)}{RT_1} =\dfrac{kx_1L_1}{RT_1} $$
$$n=\dfrac{(2000)(0.02)(0.10)}{(8.31)(300)}=\bf 0.00160\;\rm mol$$
The work done on the gas is given by
$$W=-\int PdV$$
where $P=kx/A$ and hence $dV=Adx$
$$W=-\int_{x_1}^{x_2} \dfrac{kx}{A}(Adx) =-k\int_{x_1}^{x_2} xdx$$
$$W=\dfrac{-kx^2}{2}\bigg|_{x_1}^{x_2}=\dfrac{-k}{2}(x_2^2-x_1^2)$$
Plugging the known;
$$W =\dfrac{-2000}{2}(0.08^2-0.02^2)=\bf -6\;\rm J$$
Plugging all the known into (1);
$$Q=(0.00160)(12.5)(1920-300)-(-6)=\color{red}{\bf 38.4}\;\rm J $$