7-110 产量统计(计算A村各类农作物的产量)

7-110

#include "stdafx.h"
#include <iostream>
using namespace std;

class Cun_A
{
public:
    Cun_A(double x,double y,double z)      //带参数的构造函数
    {
        acer_veget=x;
        acer_fruit=y;
        acer_grain=z;
    }
    ~Cun_A(){}           //析构函数
    void SetPerProduct(double a,double b,double c)
    {
        output_per_acerV=a;
        output_per_acerF=b;
        output_per_acerG=c;
    }
    void veget()          //蔬菜
    {
        double result=acer_veget*output_per_acerV;
        cout<<"A村蔬菜的产量为:"<<result<<endl;
    }
    void fruit()           //水果
    {
        double result=acer_fruit*output_per_acerF;
        cout<<"A村水果的产量为:"<<result<<endl;
    }
    void grain()              //稻谷
    {
        double result=acer_grain*output_per_acerG;
        cout<<"A村稻谷的产量为:"<<result<<endl;
    }
private:
    double acer_veget;         //蔬菜作物的占地
    double output_per_acerV;    //每亩地产蔬菜多少
    double acer_fruit;        //水果作物的占地
    double output_per_acerF;   //每亩地产水果多少
    double acer_grain;     //稻谷作物的占地
    double output_per_acerG;   //每亩地产稻谷多少
};


int _tmain(int argc, _TCHAR* argv[])
{
    Cun_A A(1.2,2,3);   //类对象
    A.SetPerProduct(500,400,700);   //设置产量
    A.veget();  //计算蔬菜产量
    A.fruit();   //计算水果产量
    A.grain();   //计算稻谷产量
    getchar();
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值