To calculate the net work done when a ball of mass $m$ falls on a vertical spring and compresses it by distance $d$, we use the principle of conservation of energy. Here is the step-by-step solution:
Thus, $mg(h+d)-\frac{1}{2}kd^2$ is the correct answer.