M[a_,b_,k_]:=Module[{Δ},If[IntegerQ[k]&&k>0,Δ=((b-a)/k);Δ(∑_(i=0)^(k-1))f[(Δ/2)+i Δ+a],Print["k is bad, try again"]]]//N
T[a_,b_,k_]:=Module[{Δ},If[IntegerQ[k]&&k>0,Δ=((b-a)/k);(Δ/2)(f[a]+2(∑_(i=1)^(k-1))f[i Δ+a]+f[b]),Print["loser, k is bad, try again"]]]//N
S[a_,b_,k_]:=Module[{ktest},If[EvenQ[k],(1/3)T[a,b,(k/2)]+(2/3)M[a,b,(k/2)],Print["k must be even"]]]

f[x_]:=(E^(3x));

M[0,2,8]
T[0,2,8]
S[0,2,9]