C++——圆型游泳池如图所示,现在需在其周围建一圆型过道,并在其四周围上栅栏。栅栏价格为35元/米,过道造价为20元/平方米。过道宽度为3米,游泳池半径由键盘输入。要求编程计算并输出过道和栅栏的造价。

没注释的源代码

#include <iostream>

using namespace std;

class rate

{

public:

    void input();

    void output();

private:

    double r;

    double price1,price2;

};

int main()

{

    rate t1;

    t1.input();

    t1.output();

    return 0;

}

void rate::input()

{

    cout<<"请输入游泳池的半径:";

    cin>>r;

}

void rate::output()

{

    price1=((2*3.14*r+2*3.14*(r+3))*35);

    cout<<"栅栏的价格是:"<<price1<<"元"<<endl;

    price2=((3.14*(r+3)*(r+3)-(3.14*r*r))*20);

    cout<<"过道的价格是:"<<price2<<"元"<<endl;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值