Answer
See the detailed answer below.
Work Step by Step
First, we need to sketch the problem, as seen below.
a) The speed of the box just before reaching the rough surface is its speed at the bottom of the incline.
Since the incline is frictionless, then the energy is conserved.
$$E_{top}=E_{bottom}$$
$$K_{top}+U_{g,top}=K_{bottom}+U_{g,bottom}$$
$$\frac{1}{2}mv^2_{top}+mgy_{top}=\frac{1}{2}mv^2_{bottom}+mgy_{bottom}$$
We chose the bottom of the incline to be our origin at which $y=0$. We also know that the box starts from rest.
So that,
$$0+ \color{red}{\bf\not} mgy_{top}=\frac{1}{2} \color{red}{\bf\not} mv^2_{bottom}+0$$
Thus,
$$v_{bottom} =\sqrt{2 gy_{top} }$$
Plugging the known;
$$v_{bottom} =\sqrt{2 \times 9.8\times 5 }=\color{red}{\bf 9.9}\;\rm m/s$$
____________________________________________
b)
The speed of the box just before hitting the spring is its speed after traveling 2m horizontally on the rough surface.
We can use the work-kinetic energy law since the gravitational potential energy is constant.
The work done by the friction force is given by
$$W_{f_k}= \Delta K=K_f-K_{bottom}$$
$$W_{f_k}=\frac{1}{2}mv^2_{f}-\frac{1}{2}mv^2_{bottom} $$
$$f_kd\cos180^\circ =\frac{1}{2}mv^2_{f}-\frac{1}{2}mv^2_{bottom} $$
Recalling that $f_k=\mu_kF_n$
$$-\mu_kF_nd =\frac{1}{2}mv^2_{f}-\frac{1}{2}mv^2_{bottom} $$
By applying Newton's second law we got the normal force
$$F_n=mg$$
$$-\mu_k \color{red}{\bf\not} m g d =\frac{1}{2} \color{red}{\bf\not} mv^2_{f}-\frac{1}{2} \color{red}{\bf\not} mv^2_{bottom} $$
Solving for $v_f$ which is the speed of the box just before it hits the spring.
$$-2\mu_k g d = v^2_{f}- v^2_{bottom} $$
$$ v^2_{f}= v^2_{bottom} -2\mu_k g d $$
$$ v_{f}=\sqrt{ v^2_{bottom} -2\mu_k g d }$$
Plugging the known;
$$ v_{f}=\sqrt{ 9.9^2-(2\times 0.25\times 9.8\times 2) }$$
$$v_{f} =\color{red}{\bf 9.39}\;\rm m/s$$
____________________________________________
c) We can use the conservation of energy, just before the box hits the spring and after that when the box stops, to find the compressed distance of the spring.
$$E_i=E_f$$
We choose the system to be the box+ the spring+ the rough surface.
$$K_i+U_{is}=K_f+U_{fs}+\Delta E_{th}$$
$$\frac{1}{2}mv_i^2+\frac{1}{2}kx_i^2=\frac{1}{2}mv_f^2+\frac{1}{2}kx_f^2+\mu_kmg d$$
The thermal energy is due to friction but since the ground under the spring is zero, then there is no thermal energy produced here.
The initially compressed instance of the spring is zero, so the initial elastic potential energy is zero. Also, the final kinetic energy of the box is zero since it comes to rest.
$$\frac{1}{2}mv_i^2+0=0+\frac{1}{2}kx_f^2+0$$
where $v_i$ here is the speed found in part b, which is the speed of the box just before it hits the spring. Thus, $v_i=v_f$.
$$\frac{1}{2}mv_f^2=\frac{1}{2}kx_f^2$$
where $d$ here is equal to $ x_f$ which is the compressed distance of the spring.
$$\frac{1}{2}mv_f^2=\frac{1}{2}kx_f^2 $$
$\times 2$;
$$ mv_f^2= kx_f^2 $$
Thus,
$$ x_f =\sqrt{\dfrac{ mv_f^2}{k}}$$
Plugging the known;
$$ x_f =\sqrt{\dfrac{ 5\times 9.39^2}{500}}$$
$$x_f=\color{red}{\bf 0.939}\;\rm m$$
____________________________________________
d) To find the number of trips back and forth, we need to divide the initial energy of the box at the top point on the incline by the box's lost energy due to friction.
$$N=\dfrac{E_i}{E_f}=\frac{U_{ig}}{W_{f_k}}$$
$$N= \frac{ \color{red}{\bf\not} m \color{red}{\bf\not}gy_{top}}{\mu_k \color{red}{\bf\not} m \color{red}{\bf\not}g d }$$
Plugging the known;
$$N= \frac{ 5}{0.25\times 2}=\color{red}{\bf10}\;\rm times$$