Answer
The work done by the spring on the block is $~~2.1~J$
Work Step by Step
The work that we do on the block must be equal in magnitude to the work done on the block by the spring.
When $d = 3.0~cm,$ the work done on the block is $0.9~J$
We can find the spring constant $k$:
$\frac{1}{2}kd^2 = 0.9~J$
$k = \frac{(2)(0.9~J)}{d^2}$
$k = \frac{(2)(0.9~J)}{(0.030~m)^2}$
$k = 2000~N/m$
We can find the work done by the spring on the block as the block moves from $x_i = 5.0~cm$ to $x_f = -2.0~cm$:
$W = \frac{1}{2}kx_i^2-\frac{1}{2}kx_f^2$
$W = \frac{1}{2}k~(x_i^2-x_f^2)$
$W = \frac{1}{2}(2000~N/m)~[(0.050~m)^2-(-0.020~m)^2)]$
$W = 2.1~J$
The work done by the spring on the block is $~~2.1~J$.