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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
|
//This program will be able to have the user choose from the menu and decide which equation to perform.//
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
const double pi = 3.14159;
double radius, height, base, x, y;
double hyp, Ac, Vp, Vs, Vc;
// where hyp is hypotenuse, Ac is area of a circle, Vp is volume of a pyramid, Vs is volume of a sphere, and Vc is volume of a cone. //
int input;
cout << " Choose a number 1-5 based on what you want to calculate.\n.";
cout << " 1.)Calculate Volume of a cone. \n.";
cout << " 2.)Calculate the volume of a sphere. \n.";
cout << " 3.)Calculate the hypotenuse of a right triangle. \n.";
cout << " 4.)Calculate the Volume of a pyranid with a square base. \n.";
cout << " 5.)Calculate the area of a cirle. \n.";
cin >> input;
switch (input)
{
case 1:
cout << " please enter the radius in inches of the cone. \n.";
cin >> radius;
cout << "please enter the height of the cone in inches \n.";
cin >> height;
// The volume of the cone equation. //
Vc = ( 1.0 / 3.0 ) * pi * pow(radius,2) * height;
cout << "The volume of the cone is: " << Vc << " inches^3. \n\n";
break;
case 2:
cout << " Please enter the radius of the sphere in inches. \n.";
cin >> radius;
// The volume of the sphere equation. //
Vs = ( 4.0 / 3.0 ) * pi * pow(radius,3);
cout << "The volume of the sphere is:" << Vs << "inches^3. \n\n";
break;
case 3:
cout << " Please enter the the value of the one of the legs in inches \n";
cin >> x;
cout << " please enter the value of the other leg in inches. \n";
cin >> y;
//The equation to find the hypotenuse.//
hyp = sqrt(pow(x,2) * pow(y,2));
cout << "The value of the hypotenuse is:" << hyp << "inches^2 \n\n";
break;
case 4:
cout << " please enter the base of the pyramid in inches \n";
cin >> base;
cout << " please enter the value of the of the height in inches \n.";
cin >> height;
// The equation of the volume of the pyramid. //
Vp = ( 1.0 / 3.0 ) * base * height;
cout << "The volume of the pyramid is" << Vp << "inches^3 \n.";
break;
case 5:
cout << " please enter the radius of the circle in inches \n.";
cin >> radius;
//The equation of area of a circle.//
Ac = pi * pow(radius,2);
cout << " The area of the circle is:" << Ac << " inches^2 \n";
break;
system ( "pause");
}
return(0);
}
|