Start by assigning names: Let R be the radius of the cylinder and h the height. The volume of that cylinder is and its surface area is . The two hemispherical caps must have the same radius, R, and so have total volume and surface area .

We can, without loss of generality, take the cost of the cylinder to be 1 times its area and so the cost of two hemispheres is twice their area:

We want to minimize subject to the constraint that .

At this point I don't know how to help you further since there are several ways to do that and I don't know which would be appropriate for you. I would consider "Lagrange multipliers" to be best. Do you know that method.

By the way, the volumecan'tbe "1000 mg". mg is a measure of mass, not volume. Did you mean 1000 ml or 1000 cc?