PE reference point is where spring is at rest.
We need to find the total initial energy of the system and then use that number to find the things that are unknown.
Initial Conditions:
Just before the block hits the spring, some of the PE has been lost to friction and the rest has been converted to KE.
The energy lost to friction is the work done by friction:
This energy is taken off from the total initial energy to see how much mechanical energy the block has just before hitting the spring. E=122.5J-63.7J=58.8J
Because we chose the reference of PE to be where the spring is at rest, the PE at this point is zero. Therefore all this energy is kinetic.
When the block touches the spring, it moves to a region of no friction. The spring will compress a certain distance (part b.), but the only thing that we are concerned with right now is the energy that the block is returned with by the spring. Because there is no friction, the spring just changes the direction of the movement, but returns all the energy that the block started out with. Therefore it still has 58.8J of kinetic energy, but the direction of the velocity is up the ramp now.
We now solve the problem of how far the block will move up the ramp (friction included again) with initial energy of 58.8J Some of the energy will be lost to friction, while the rest will be converted to PE. The kinetic energy of the block at it's highest point will be zero because it is at rest there, so we can just equate the amount of energy we have to the work done by friction and the change in potential energy. Then we just solve for d.
The energy lost to friction is the work done by friction: