Is work change in energy or force times displacement? Recently I had an exam which had the following question:

For section a, I know that the work gravity has done is the force component parallel to the surface times the distance the block has travelled until it stops. Which is about 21 Joules, therefore gravity has done positive work.
For section b, the spring applies a force in the opposite direction of movement so it does negative work and at some point, it stops the block leaving it with 0 potential (I took the height 0 at the blocks lowest possible position) and 0 kinetic energy. So the spring does -21 Joules of work on the block.
The problem lies on the section c. Work is defined as the change in energy and it is Force x Displacement. When we consider the blocks initial and final energies, the block has 21 Joules of gravitational potential energy and nothing more at the initial time, but at the final time the block has 0 potential and 0 kinetic energy therefore 0 total energy (system is mechanical). Because work is the change in energy, this means that -21 Joules of work has been done on the block.
However, when we consider this problem with the forces applied on the block in the time interval, the answer seems to have changed. There are 2 forces applied on the block throughout its journey; gravity and spring force. Work done on the block is the work done on the block by gravity + the work done on the block by spring. Two of which we have calculated in sections a and b. So the work done on the block is 21 Joules - 21 Joules = 0 Joules.
So which one is it? -21 Joules or 0 Joules?
 A: You can either use the concept of potential energy or use the concept of work done by gravity. However, because change in PE of block = work done against gravity = - work done by gravity, then if you use both concepts then you are double counting this work.
So you can either say
work done by gravity on block + work done by spring on block = change in KE of block = 0 Joules
or you can say
work done by spring on block = change in PE of block + change in KE of block = -21 Joules
But you are trying to say
work done by gravity on block + work done by spring on block = change in PE of block + change in KE of block
which is incorrect.
A: In short, you can use the Law of conservation of energy to solve this problem. Since the mass starts and ends at the velocity zero, it means that the kinetic energy does not change $\Delta K = 0$ and by the work-energy theorem the total work on the object is therefore $W = 0$. This also means that the gravitational potential energy at the top of the slope is all converted to the elastic potential energy when the mass stops, but you have to be careful about the signs!
I show below in detail how energy is related to force, and how is this all related to the concept of kinetic energy.

The definition of work is force times distance. For a constant force $F$ acting along some distance $s$ the work is defined as:
$$W = F s$$
Since both force and distance are vectors, the more formal definition would be via scalar product. For a constant force, the work is
$$W = \vec{F} \cdot \vec{s} = |\vec{F}| |\vec{s}| \cos\theta$$
where $\theta$ is angle between the two vectors. But let’s limit the analysis to 1D case in which force acts in the same direction as distance.
The distance and velocity are defined as:
$$x_2 = \frac{1}{2} a t^2 + v_1 t + x_1 \quad \text{and} \quad v_2 = a t + v_1$$
From the above two equations you can eliminate the time variable:
$$v_2^2 = v_1^2 + 2a\Delta x$$
where $\Delta x = x_2 - x_1$. Note that by second Newton’s law the net force equals $F = ma$ and the above equation becomes
$$\frac{1}{2} m v_2^2 = \frac{1}{2} m v_1^2 + F \Delta x$$
With $W = F \Delta x$ and $K = \frac{1}{2} m v^2$, where $K$ is called kinetic energy, this finally leads us to the work-energy theorem:
$$K_1 + W = K_2$$
which can also be written as
$$\boxed{\Delta K = K_2 - K_1 = W} \tag 1$$
This means that the change in kinetic energy $\Delta K$ equals work done on the object, whereas work is defined via force and distance.
This entire derivation is done for the constant force $F$. The final expressions are the same for a force that changes along the path,  but the derivation would include infinitesimal small values (calculus), i.e. $\Delta x \to 0$.

In this second part I introduce the concept of gravitational potential and elastic potential energy.
Let the positive direction of y axis point upwards (away from the Earth's center). Then the gravitational force acting on the object and the work done by the gravitational force are
$$\vec{F}_g = - m g \hat{y} \quad \text{and} \quad W_g = -m g (y_2 - y_1) = - \Delta U_g$$
where $\hat{y}$ is the unit vector pointing upwards, and $U_g = mgy$ is called the gravitational potential energy.
Let the $x = 0$ be at the position at which spring elongation is zero. Then the elastic force acting on the object and the work done by the elastic force are
$$\vec{F}_e = -kx \hat{x} \quad \text{and} \quad W_e = -\frac{1}{2}k(x_2^2 - x_1^2) = -\Delta U_e$$
where $\hat{x}$ is the unit vector pointing along the spring, and $U = \frac{1}{2}kx^2$ is called the elastic potential energy. Note that the elastic force is always trying to return the spring to the zero elongation.
Now we can redefine the Eq. (1) as follows:
$$\boxed{\Delta K + \Delta U_g + \Delta U_e = W_\text{other}} \tag 2$$
where $W_\text{other}$ is the work done by forces other than gravitational and elastic.

From all this it is now trivial to calculate the values for your problem. You first find the force constant of the spring:
$$k = \frac{270 \text{ N}}{0.02 \text{ m}} = 13500 \text{ N/m}$$
Let the point 1 be at the top of the spring and point 2 where the spring is compressed 5.5 cm. The height difference between points 1 and 2 is
$$\Delta h = y_1 - y_2 = l \cdot \sin\theta = 0.0275 \text{ m}$$
and the work done by the gravitational potential energy between points 1 and 2 is:
$$W_{g21} = -mg(y_2 - y_1) = -\Delta U_{g21} = 3.234 \text{ J}$$
From Eq. (2) it is possible to calculate the kinetic energy when the mass reaches point 1:
$$\Delta K_{21} + \Delta U_{g21} + \Delta U_{e21} = 0 \quad \rightarrow \quad K_1 = 17.18475 \text{ J}$$
where $K_2 = 0$ and
$$\Delta U_{e21} = \frac{1}{2} k (x_2^2 - x_1^2) = \frac{1}{2} \cdot 13500 \cdot (0.055^2 - 0^2) = 20.41875 \text{ J}$$
Let point 0 be at the top of the slope where the mass is at rest, then
$$\Delta K_{10} + \Delta U_{g10} = 0 \quad \rightarrow \quad \Delta U_{g10} = -K_1$$
because $K_0 = 0$. Then the total work by the gravitational and elastic forces is
$$W_g = -(\Delta U_{g10} + \Delta U_{g21}) = 20.41875 \text{ J} \quad \text{and} \quad W_e = -\Delta U_{e21} = -20.41875 \text{ J}$$
Since the block starts and ends at the velocity zero, this means that all gravitational potential energy is converted to the elastic potential energy. The total work on the object is exactly 0 J.
A: The work done by gravity on the block is +21 J. But the NET work done on the block (gravity +spring) is zero. The work energy theorem states that the net work done on an object equals its change in kinetic energy. Since the block begins at rest and comes to rest when it is temporarily stopped by the spring, its change in kinetic energy is zero, meaning the net work done on the block is zero.
What this simply means is the negative work done by the spring takes the positive work done by gravity (at the expense of gravitational potential energy) and stores it as elastic potential energy of the spring.
Hope this helps.
