Solution :

Since O2 is a diaatomic gas

CP=7R/2,CV=5R/2

Molecular mass=32 gm

Intial state

Intial volume of gas

V=nRT/P

n=1*103/32

T=303K

R=8.3

P0=500*103 N/m2

so V=.157 m3

Second state ( when piston reaches the spring)

v=.2 m3

P=500*103 N/m2

As per ideal gas equation

Temperature becomes=385.5 K

So heat tranfer till that point=nCP(T2 -T1)

=1*103 *7*8.3*82.5/32*2

=74.8 KJ

Third state ( when it compresses the spring)V=.2+0.1*0.25=0.225 m3

P=500*103 + kx/A

=500*103 + 120*103*25*10-2/.1

=800*103 N/m2

As per ideal equation

Temperature becomes=694K

Change in Internal energy=nCV(T3 -T2)=5nR(T3 -T2)/2

=5*1*103*8.3*308.5/32*2

=200 KJ

Workdone by the gas =P0Ax + kx2/2

=500*103*.1*.25 + 120*103*.25*.25/2

=16.25 KJ

Total heat supplied in this Process=200+16.25=216.25KJ

So net Heat transfer=291.05 KJ