#include <iostream>
#include <cmath>
usingnamespace std;
double calculate_radius(double radius)
{
while (radius <=0)
{
cout<< radius <<" is not a valid entry for the radius!"<<endl;
cout<< "Please enter a value greater than 0 for the radius.";
cin>>radius;
}
return radius;
}
double calculate_height(double height)
{
while (height <=0)
{
cout<< height <<" is not a valid entry for the height!"<<endl;
cout<< "Please enter a value greater than 0 for the height.";
cin>>height;
}
return height;
}
double calculate_volume(double radius, double height, double volume)
{
constdouble PI = 3.14159;
volume = PI*pow(radius, 2.0)*height;
return volume;
}
double calculate_sufacearea(double radius, double height, double surface_area, double PI)
{
surface_area = 2*PI+2*PI*radius*height;
return surface_area;
}
int main ()
{
double radius, height, volume, surface_area;
cout << "Please enter the radius of the cylinder.";
cin >> radius;
calculate_radius(radius);
cout << "Please enter the height of the cylinder.";
cin >> height;
calculate_height(height);
cout << "A cylinder with radius of " << radius << " and a height of " << height ;
cout <<" has a volume of " << volume << " and a surface area of " <<surface_area;
}
When this program runs, volume is output at 0 and surface area is 8.69289e-311