A moving railway compartment has a spring of constant k fixed to its front wall. A boy stretches this spring by distance x and in the mean time the compartment moves by a distance s. The work done by boy w.r.t. earth is
12kx2
Total work done is equal to the energy stored in the spring.