#10, p. 307

Clear[MID]

f[x_]:=Cos[x]^4
a=0;
b=Pi/2;
n=4;

MID[a0_,b0_,m0_]:=
Module[{a=N[a0],b=N[b0],m=m0,k},
h = (b-a)/m; 
start=a+h/2; 
Print[{"x_i","f(x_i)" }];
sum=0;
For[ k=0, k≤m-1, k++, 
sum=sum+f[start+k*h ];
Print[{start+k*h,f[start+k*h ]}]
 ];  
Return[ h*sum ];
 ];

MID[a,b,n]