Which Has a Larger Volume a Cylinder or a Truncated Cone? The following link describes a programming problem. However, I am unable to work out the maths for the problem.

We are given $r$ – radius of lower base and $s$ – slant height. The figure can be cylinder or truncated cone. You have to find as largest volume as possible to carry oil respect to given information.
You are given two numbers that less than 100: radius $r$ of lower base and slant height $s$. The slant height is the shortest possible distance between the edges of two bases.

EDIT suggested :
Given $ \sqrt{(R-r)^2 + h^2 }$ and $ r,$  find $ h/r $ ratio.
$~~~~~~~~~~~~~~~~$
 A: See on comparing volume we get to see that volume of cylinder $<$ volume of truncated cone as $r^2<(r^2+R^2-rR)$. Thus from here you can setup equations and differentiate it with radius and then put it to be $0$ for maxima and the condition for maxima is $f''(x)<0$
A: If the constant slant height and base radius are $s, r$ respectively and the variable angle which the slanting face makes with the vertical is $\theta$ then the height and top radius of the frustum are
$$h=s\cos\theta, R=r+s\sin\theta$$
The volume of the frustum is $$V=\frac13 \pi h (R^2+Rr+r^2)$$
Now $$\frac{dh}{d\theta}=-s\sin\theta, \frac{dR}{d\theta}=s\cos\theta$$
Volume is maximum when
$$\frac{dV}{d\theta}=\frac13 \pi [\frac{dh}{d\theta}(R^2+Rr+r^2)+h(2R\frac{dR}{d\theta}+r\frac{dR}{d\theta})=0$$
$$-s\sin\theta (R^2+Rr+r^2)+s\cos\theta(2Rs\cos\theta+rs\cos\theta)=0$$
$$-s\sin\theta (3r^2+3rs\sin\theta+s^2\sin^2\theta)+s^2(1-\sin^2\theta)(3r+2s\sin\theta)=0$$
$$- (3r^2\sin\theta+3rs\sin^2\theta+s^2\sin^3\theta)+(3rs+2s^2\sin\theta-3rs\sin^2\theta-2s^2\sin^3\theta)=0$$
$$3x+(2-3x^2)y-6xy^2-3y^3=0$$
where $x=r/s$ and $y=\sin\theta$.
In general the cubic equation will have to be solved numerically. In the special case $s=r$ so that $x=1$ we have $3-y-6y^2-3y^3=0$. The only real root is $y=\sin\theta\approx 0.56298, \cos\theta\approx 0.82647$. Then the maximum volume is $V\approx 4.33$ as found in the link. Whereas for the cylinder $V=\pi\approx 3.14$.
