There are two important cases where Conservation of Mechanical Energy can be used.
First is the case where all of the forces acting on the body are conservative or path independent forces. In this course the only two conservative forces are gravitational and spring forces. This condition also is true when the non-conservative forces are present but do no work (for example the normal force frequently does no work). For this case
K2 + U2 = K1 + U1
where K1and K2 are the kinetic energy of a body at positions 1 and 2 and U1 and U2 are the potential energy of the body at positions 1 and 2. The potential energy for a spring is given by
Us = .5*k*d^2
where k is the spring constant of the spring in N/m and d is the displacement
of the end of the spring from its equilibrium position.
The potential energy for a body of mass m near a planet is given by
Ug = m*g*h
where m is the mass of the body, g is the "acceleration of gravity"
near the surface of the planet and h is the height in meters above some
reference position.
The potential energy for a mass at a greater distance from the surface
of a planet is given by
UG = - G*m*Mp/r
where G = 6.67E-11 N*m^2/kg^2, Mp is the mass of the planet and r is the distance from the center of the planet to the center of the body of mass m.
The second case for application of Conservation of Mechanical Energy is when there are non conservative forces in addition to the conservative forces. Examples of non conservative forces are friction and applied forces like "pushes". In this case the Conservation of Mechanical Energy becomes
K2 + U2 = K1 + U1 + W12(non conservative)
where W12(non conservative) is the work done on the body by the nonconservative forces. Note that this work can be negative when the force and displacement are in different directions!