Physics 220 Exercise on potential energy
  The object is launched by a spring and slides along the frictionless surface shown. What spring compression is required to get the object to the top of the ramps? Take k = 100 N/m, m = 0.5 kg.

This is an energy conservation problem. The "before" state is the object on the end of the compressed spring, and the "after" state is the object at the top of the ramps, at rest. We put the reference level for gravitational PE at the level of the spring. Then the energies are:

  Before After
Spring PE ks2/2 0
Gravitational PE 0 mgh
Total PE ks2/2 mgh

  Since it does not matter how the object got into each state, the only thing that matters in the final GPE is the total height h = 2 m + 3 m = 5 m. Setting total energy before equal to total energy after, we have