A Generalisation of the Trapezoidal Rule for the Riemann-Stieltjes Integral and Applications