Use the general formula:
Volume = Height * (area of top+4*area at mid height+area at bottom) /6
Example for a cube of side s:
Vcu=s(s^2+4s^2+s^2)/6=s^3
Example for a cone of radius r
Vco=h(0+4*pi r^2/4+pi r^2)/6=pi r^2 h/3
Example for a sphere or radius r:
Vsph=2r*(0+4pi r^2 + 0)/6 = 4pi r^2 /3
So for a square frustrum with end sides a & b, height h:
Vf=h*(a^2+4((a+b)/2)^2+b^2)/6=(a^2+(a+b)^2+b^2)h/6
or simply
Vf=(a^2+(a+b)^2+b^2)h/6