I'm supposed to be writing a program that computes the volume of water in a water tower given the height.
This is the water tower we're supposed to be calculating the volume for:
http://postimg.org/image/yzfqehfcn/
Volume of cylinder: π * r2 * h
Volume of truncated cone: 1/3 * π * ( r1^2 + r1*r2 + r2^2) * h
Difference of radius in conical section: same as height in conical section
PI is a constant variable of 3.1415926
Now on my rubric it has the following:
Correctly Calculate The Water Volume :
1) For height greater than 0 but less than or equal to 20
2) For height greater than 20 but less than or equal to 30
3) For height greater than 30 but less than or equal to 40
4) For height greater than 40 but less than or equal to 50
So this is what I have so far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

#include <iostream>
#include <cmath>
using namespace std;
int main()
{
const double PI = 3.1415926, r1 = 15, r2 = 25;
double height, cylinder1, cone1;
cout << "Enter height of water in tower: ";
cin >> height;
cylinder1 = PI*(r1*r1)*height;
if (height>0 && height<=20)
{
cout << "With a height of " << height << " feet, the volume is " << cylinder1 << " cubic feet." << endl;
}
cout << "Enter height of water in tower: ";
cin >> height;
if (height>20 && height<=30)
cone1 = (1.0/3.0)*PI*((r1*r1)+r1)*((r2*r2)+r2)*height
{
cout << "With a height of " << height << " feet, the volume is " << cone1 << " cubic feet." << endl;
}
return 0;
}
 
When I run the program, the first if statement works, however the second one does not.
I'm not sure if I should be using switch statements instead, I need to be able to do each separate statement, but I thought I couldn't use ranges in switch statements.
Also, I know the second if statement is wrong because to get the full volume up to that point, I need to add the volume of the first part of the water tower, but i'm not sure how to do that.
I would really appreciate it if anyone could help and point me in the right direction