c++ 计算指定半径圆的面积

 

#include <iostream>
#define PI 3.14
using namespace std;
class Circle
{
    float radius;
public:
    void getRadius();
    float area();
    void showRadius();
};

void Circle :: getRadius()
{
    cout << "Enter Radius ::: ";
    cin >> radius;
}

float Circle :: area()
{
    float ar;
    ar = PI * radius * radius;
    return ar;
}

void Circle :: showRadius()
{
    cout << "\n Radius : " << radius;
}

int main()
{
    Circle c1;
    
    c1.getRadius();
    c1.showRadius();
    float a = c1.area();
    cout << "\n Area of Circle : " << a;
    return 0;
}

 

posted @ 2018-11-23 21:19  anobscureretreat  阅读(2032)  评论(0编辑  收藏  举报