//Computes the area of a circle and the volume of a sphere. //Uses the same radius for both calculations. #include #include const double PI = 3.14159; double area(double radius); //Returns the area of a circle with the specified radius. double volume(double radius); //Returns the volume of a sphere with the specified radius. void get_input(double& radius); void show_results(double radius, double area, double volume); int main( ) { double radius_of_both, area_of_circle, volume_of_sphere; get_input(radius_of_both); area_of_circle = area(radius_of_both); volume_of_sphere = volume(radius_of_both); show_results(radius_of_both, area_of_circle, volume_of_sphere); return 0; } double area(double radius) { return (PI * pow(radius, 2)); } double volume(double radius) { return ((4.0/3.0) * PI * pow(radius, 3)); } //Uses iostream.h: void get_input(double& radius) { cout << "Enter a radius to use for both a circle\n" << "and a sphere (in inches): "; cin >> radius; } //Uses iostream.h: void show_results(double radius, double area, double volume) { cout << "Radius = " << radius << " inches\n" << "Area of circle = " << area << " square inches\n" << "Volume of sphere = " << volume << " cubic inches\n"; }