Maximizing volume of a cylinder with $2$ cones given surface area $A$ A cylinder with a cone on either side of it. The cones have the same radius as the cylinder.
Cylinder area without the sides:
$$A_{cyl}=2\pi r h_1$$
Cone area without the base:
$$A_{cone}=\pi r \sqrt{h_2^2+r^2}$$
Total area of body:
$$A_{tot}=2\pi r h_1 + 2\pi r \sqrt{h_2^2+r^2}$$
Volume:
$$V_{tot}=\pi r^2 h_1 +\frac{2\pi r^2 h_2}{3}=\pi r^2 (h_1 + \frac{2}{3}h_2)$$
I have managed to calculate the maximum volume given surface area for the cone and the cylinder separately but together there are three variables. How would I go about calculating $r,h_1,h_2$ to maximize the volume?

Since $\frac{A_{tot}}{2\pi}\geq \max\{rh_1+rh_2,r^2\}$, it follows that $r$ is bounded and the volume has to be finite:
$$V= \pi r\left(rh_1+\frac{2}{3}rh_2\right)\leq \pi r \frac{A_{tot}}{2\pi}\leq  \frac{A_{tot}^{3/2}}{2\sqrt{2\pi}}.$$
Moreover the above inequality implies that $V\to 0$ as $r\to 0$. So we may assume that $r\geq r_0$ where $r_0>0$ is sufficiently small. Then
also the positive variables $h_1$ and $h_2$ have to be bounded.
Now we apply the method of Lagrange multipliers to the function
$$V(r,h_1,h_2)=\pi r^2 h_1 +\frac{2\pi r^2 h_2}{3}=\pi r^2 \left(h_1 + \frac{2}{3}h_2\right)$$
subject to the constraint
$$A(r,h_1,h_2)=2\pi r \left(h_1 + \sqrt{h_2^2+r^2}\right)=A_{tot}.$$
Assuming $r\geq r_0$, $h_1>0$, $h_2>0$ we find
just one constrained stationary point (which has to be the maximum):
$$\begin{cases}
\frac{\partial V}{\partial r}=\lambda\frac{\partial A}{\partial r}\\
\frac{\partial V}{\partial h_1} =\lambda\frac{\partial A}{\partial h_1}\\
\frac{\partial V}{\partial h_2}=\lambda\frac{\partial A}{\partial h_2}
\end{cases}
\implies
\begin{cases}
r \left(h_1 + \frac{2}{3}h_2\right)=\lambda \Big(h_1 + \sqrt{h_2^2+r^2}+\frac{r^2}{\sqrt{h_2^2+r^2}}\Big)\\
 r^2 =\lambda 2r\\
\frac{r^2}{3} =\lambda \frac{r h_2}{\sqrt{h_2^2+r^2}}
\end{cases}
\implies 
\begin{cases}
\lambda=\frac{r}{2}\\h_1=h_2=\frac{2r}{\sqrt{5}}
\end{cases}$$
where $r$ is given by
$$A_{tot}=2\pi r \left(\frac{2r}{\sqrt{5}} +  \sqrt{\frac{4r^2}{5}+r^2}\right)\implies r=\sqrt{\frac{A_{tot}}{2\pi\sqrt{5}}}.$$
Hence, given the surface area $A_{tot}$, the maximum  volume is
$$V=\pi r^2 \frac{2r}{\sqrt{5}}\left(1 + \frac{2}{3}\right)=
\frac{2\pi\sqrt{5} }{3}r^3=
\frac{A_{tot}^{3/2}}{3\sqrt{2\pi}\,5^{1/4}}.$$
Note that the maximal shape has an inscribed sphere of radius $r$:

