To use symbolic constants, nested decisions, and sentinel loops.
Volume = 4.0/3.0*Pi*r^3 (^ means to the power of in case you didn't know but I know probably you know... smart ass)
Surface Area = 4.0*Pi*r^2
Cross-Sectional Area = Pi*r^2
iostream, cmath, iomanip
#include iostream
#include cmath
#include iomanip
using namespace std;
const char QUIT = 'Q';
const float PI = 3.1415927;
int main()
{
float radius, surface_area, volume, cross_section;
char method;
cout << "Please enter\n"
<< "V for volume,\n"
<< "A for surface area"
<< ",X for cross-sectional area,\n"
<< "and finally Q if you would like to quit.\n";
cin >> method;
while (method != QUIT) {
cout << "Now please enter the radius of your sphere.\n";
cin >> radius;
if (method == 'V') {
volume = 4.0 / 3.0 * PI * radius * radius * radius;
cout << "The volume of the sphere is:" << volume<> method;
}
system("pause");
return 0;
}
A 15.9
X 12.8
V 34.8
A 23.8
Q (The sentinel)
Just look at the friggin file right up in here that I provided your a**.Please enter
V for volume,
A for surface area,X for cross-sectional area,
and finally Q if you would like to quit.
A
Now please enter the radius of your sphere.
15.9
The surface area of the sphere is:3176.9
Please enter
V for volume,
A for surface areaX for cross-sectional area,
and finally Q if you would like to quit.
X
Now please enter the radius of your sphere.
12.8
The cross section of the sphere is:514.719
Please enter
V for volume,
A for surface areaX for cross-sectional area,
and finally Q if you would like to quit.
V
Now please enter the radius of your sphere.
34.8
The volume of the sphere is:176533
Please enter
V for volume,
A for surface areaX for cross-sectional area,
and finally Q if you would like to quit.
A
Now please enter the radius of your sphere.
23.8
The surface area of the sphere is:7118.09
Please enter
V for volume,
A for surface areaX for cross-sectional area,
and finally Q if you would like to quit.
Q2nd post - hollla!