CIT020 - Midterm Practice - Working Version
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main( )
{
double height = 0.0;
double radius = 0.0;
double volume = 0.0;
const double PI = 3.1415926536;
cout << "Enter the height in centimeters: ";
cin >> height;
cout << "Enter the radius in centimeters: ";
cin >> radius;
if (height > 0 && radius > 0)
{
volume = PI * height * radius * radius;
cout << "The volume is " << volume << " cubic centimeters." << endl;
}
else
{
cout << "Both radius and height must be greater than zero." << endl;
}
system("PAUSE");
return 0;
}