第三周项目4-长方柱类

/*
* Copyright (c) 2012, 烟台大学计算机学院 
* All rights reserved. 
* 作    者:尹成真
* 完成日期:2013年 3月20日 
* 版 本 号:v1.0 
* 输入描述: 在类声明中声明成员函数
* 问题描述:略
* 程序输出:长方柱的体积和表面积
* 算法设计:
*/#include <iostream>  
using namespace std;  
class Box  
{  
public:  
    void get_value();  
    void get_display();  
private:  
	void get_volume();    
    void get_surface();  
    float lengh;  
    float width;  
    float height;  
	float volume;
	float surface;
};  

void Box::get_value()  
{   
    cout<<"请输入长,宽,高:";  
    cin>>lengh;  
    cin>>width;  
    cin>>height;  
    get_volume();    
    get_surface();  
}  

void Box::get_volume()  
{  
	volume=lengh*width*height;  
}  

void Box::get_surface()  
{  
    surface=2*(lengh*width+lengh*height+width*height);  
}  

void Box::get_display()  
{   
	
    cout<<"The volume is: "<<volume<<endl;  
    cout<<"The surface  is: "<<surface<<endl;  
}  

int main()  
{  
    Box b1,b2,b3;  
	
    b1.get_value();  
    cout<<"For box1: "<<endl;  
    b1.get_display();  
	
    b2.get_value();  
    cout<<"For box2: "<<endl;  
    b2.get_display();  
	
    b3.get_value();  
    cout<<"For box3: "<<endl;  
    b3.get_display();  
    return 0;  
}  

放上去的截图怎么看不到啊

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值