RSS

area of Circle

24 Jul

#include <iostream>

using namespace std;

class Circle{
    private:
        double radius, area;
    public:
        Circle(double r){
            radius = r;
        }
        void setRadius(double r);
        double getRadius();
        double AreaOfCircle();

};

class Cylinder: public Circle{
    private:
        double height;
    public:
        Cylinder(double r,double h);
        double SArea();
        double Volume();
        void details();
};

void Circle::setRadius(double r){
    radius = r;
}
double Circle::getRadius(){
    return radius;
}
double Circle::AreaOfCircle(){
    area = 3.142 * radius * radius;
    return area;
}
Cylinder::Cylinder(double r,double h) : Circle(r){
    height = h;
}
double Cylinder::SArea(){
    double surface_area = 3.142 * 2 * getRadius()* height + AreaOfCircle();
    return surface_area;
}
double Cylinder::Volume(){
    double volume = AreaOfCircle() * height;
    return volume;
}
void Cylinder::details(){
    cout<<"Cylinder details: "<<endl;
    cout<<"Radius: "<<getRadius()<<endl;
    cout<<"Height: "<<height<<endl;
    cout<<"Area of circle: "<<AreaOfCircle()<<endl;
    cout<<"Surface Area: "<<SArea()<<endl;
    cout<<"Volume: "<<Volume()<<endl;

}
int main()
{
    Cylinder one(7, 10);
    one.details();
    return 0;
}


Advertisements
 
Leave a comment

Posted by on July 24, 2012 in C++

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: