Approximating the Riemann–Stieltjes integral by a trapezoidal quadrature rule with applications