A toy gun uses a spring of force constant K. Before being triggered in the upward direction, the spring is compressed by a distance x. If the mass of the shot is m, on being triggered, it will go up to a maximum height of
kx22mg
According to the law of conservation of energy, elastic potential energy stored in the spring = gravitational potential energy acquired by shot
12kx2=mgh or h=kx22mg