您的位置:首页 > 其它

定义一个计算游泳池过道和栅栏造价的类

2013-10-21 11:28 197 查看
#include<iostream>
#define AisUnitP  20
#define FenUnitP  35
#define AisWidth  3
#define PI 3.14
using namespace std;

class Pool{
private:
double radius;
public:
Pool(double radius=0.0)
{
this->radius=radius;
}
double AreaA()
{
return radius*radius;
}
double AreaF()
{
return (AisWidth+radius)*(AisWidth+radius);
}
double Aisle_Price()
{
return AisUnitP*PI*(AreaF()-AreaA());
}
double Fences_Price()
{
return FenUnitP*2*PI*radius;
}
void ShowPrice()
{
cout << "the price of the aisle is:"<<Aisle_Price()<<endl;
cout << "the price of the fence is:"<< Fences_Price()<<endl;
}
};

int main()
{
double r;
cout <<"input the radius of the pool:";
cin>> r;
Pool P(r);
P.ShowPrice();
return 0;
}


 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐