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
|
/*
03-09-2015
This Program will read input values of two radius values R1 and R2, and height
It will then compute volume and return it as well as the surface area's volume
It will finally display volume and surface values as output to the user.
*/
#include <iostream>
#include <cmath> //math library function
using namespace std;
int main()
{
// Declare variables
double h, R1, R2, vol, surf;
// Volume will accept three variables as inputs: R1, R2, and h
double volume(double R1, double R2, double h);
// Define Pi
double pi = 3.14;
// Equation for volume of a cone
double V = (1 / 3)*pi*h*(pow(R1, 2) + (pow(R2, 2) + R1*R2));
// Surface will accept three variables as inputs: R1, R2, and h
double surface(double R1, double R2, double h);
{
double pi = 3.14;
// Equation for surface area of cone
double S = pi*(R1 + R2)*sqrt(pow(R2 - R1, 2) + pow(h, 2)) + pi*pow(R1, 2);
}
// Prompt and read input values of radius (R1,R2)
cout << " Please enter the radius value(R1): ";
cin >> R1;
cout << " Please enter the radius value(R2): ";
cin >> R2;
cout << " Please enter the heigh of cone(h): ";
cin >> h;
// Define the functions
vol = volume(R1, R2, h);
surf = surface(R1, R2, h);
// Display outputs
cout << " The volume of the cone= " << vol << endl;
cout << " The surface area of the cone= " << surf << endl;
system(" PAUSE ");
}
|