2.2 (30 points) (35 minutes)
The pressure vessel shown at right is made up of a cylinder with a radius, R, of 0.75m and a length, L, of
with hemispherical ends each having the same radius, R, of 0.75m.
You must write a function that will calculate the volume of water in the cylinder given the water level
in the tank as input. The function must use \"switch-case\" structure based on the value of $h$ and call three
different sub-functions. The water level is given by the variable $h$ measured from the very bottom of the
ank. If the water level does not exceed the level of the lower hemisphere, then
the volume of water, $V$, is given by the expression:
$V = \pi h^2 R - \frac{\pi}{3} h^3$
If the water level is somewhere in the straight section in the middle, then the
volu me is given by the following expression:
$V = \frac{2\pi}{3} R^3 + \pi R^2 (h - R)$
If the water level is in the upper hemisphere, then the volume is given by the
following expression:
$V = \frac{2\pi}{3} R^3 + \pi R^2 L + \pi R^2 (h - L - R) - \frac{\pi}{3} (h - L - R)^3$
Your function should have one input for water level ($h$) and one output for
water volume ($V$).