Expand|Select|Wrap|Line Numbers
- #include<iostream>
- using namespace std;
- class Circle_computations
- {
- public:
- double area,circumference,radius,pi;
- public:
- Circle_computations()
- {
- }
- Circle_computations(double radi)
- {
- pi = 3.14;
- radius=radi;
- }
- double c_area()
- {
- area = pi*radius*radius;
- return area;
- }
- double c_circumferunce()
- {
- circumference =2*pi*radius;
- return circumference;
- }
- };
- class Cylinder:public Circle_computations
- {
- protected:
- double height,volume,cyarea;
- public:
- Cylinder(double r, double h) :
- Circle_computations(r)
- {
- height = h;
- }
- double cy_area()
- {
- cyarea=(2 * (Circle_computations::c_area()))+( c_circumferunce()* height) ;
- cout<<cyarea;
- }
- double c_volume()
- {
- volume = (Circle_computations::c_area())* height;
- return volume;
- cout<<volume;
- }
- };
- int main()
- {
- double r,heigh_t;
- cout<<"**Please Enter The Radius First** \n";
- cin>> r;
- cout<<"**Please Enter The height** \n";
- cin>>heigh_t;
- try
- {
- if(r||heigh_t<=0.0)
- {
- throw "PLESE ENTER double NUMBERS";
- }
- }
- catch (char* strException)
- {
- cerr << "Error: " << strException << "\n";
- }
- Circle_computations compute(r);
- Cylinder computecylider(r,heigh_t);
- cout<<"****The cylinder surface Area is****\n";
- cout<<computecylider.cy_area();
- cout<<"\n";
- cout<<"****The cylinder volume is****\n";
- cout<<computecylider.c_volume();
- cout<<"\n";
- }