Code:
#include<iostream>
using namespace std;
class Circle_computations
{
protected:
double area,circumference,radius,pi;
public:
Circle_computations()
{
}
Circle_computations(double radi)
{
pi = 3.14;
set_r(radi);
}
double set_r(double radi)
{
try
{
if(radi<=0.0)
{
throw "PLESE ENTER positive NUMBERS";
}
radius=radi;
}
catch ( const char* strException )
{
cerr << "Error: " << strException << "\n";
return 1 ;
}
}
double get_r()
{
return radius;
}
double circle_area()
{
area = pi*radius*radius;
return area;
}
double circle_circumferunce()
{
circumference =2*pi*radius;
return circumference;
}
void print_circleoutput()
{
cout<<"****The Area OF The Circle is****\n"<<area<<"\n";
cout<<"****The Circle Circumferunce is****\n"<<circumference<<"\n";
}
};
class Cylinder:public Circle_computations
{
protected:
double height,volume,cyarea;
public:
Cylinder(double r, double h) :
Circle_computations(r)
{
set_height(h);
}
double set_height(double h)
{
try
{
if(h<=0.0)
{
throw "PLESE ENTER positive NUMBERS";
}
height=h;
}
catch ( const char* strException )
{
cerr << "Error: " << strException << "\n";
return 1 ;
}
}
double get_height()
{
return height;
}
double cylindersurface_area()
{
cyarea=(2 * (Circle_computations::circle_area()))+( circle_circumferunce()* height) ;
return cyarea;
}
double c_volume()
{
volume = (Circle_computations::circle_area())* height;
return volume;
}
void print_cylinderoutput()
{
cout<<"****The cylinder surface Area is****\n"<<cyarea;;
cout<<"****The cylinder volume is****\n"<<volume;
}
};
int main()
{
Circle_computations compute(1.5);
Cylinder computecylider(1.5,2.5);
cout<<"****The Radius is****\n";
computecylider.get_height();
computecylider.get_r();
computecylider.set_r(3.5);
computecylider.set_height(2.6);
computecylider.print_cylinderoutput();
}
Comment