Approximating the Stieltjes integral via a weighted trapezoidal rule with applications