长方柱类

Copyright (c) 2013, 烟台      
All rights reserved.      
作者:石晓涛      
完成日期:2013 年3月25日      
版本号:v1.0         
输入描述:      
     
问题描述:      
   
程序输出:      
      
算法设计:
#include <iostream>   
using namespace std;  
class Box
{
public:
	void get_doul();  //赋值
    void get_volume();            //体积
	void get_area();//表面积
	void volume_play();
	void area_play();
private:
	double height;            //高
	double width;             //宽
	double length;            //长
	double volume;			  //体积
    double area;              //面积
};
void Box::get_volume()
{
	 volume=height*width*length;
}
void Box::get_area()
{
	area=2*(height*width+height*length+width*length);
}
void Box::get_doul( )
{
	cout<<"请输入长,宽,高:"<<endl;
	cin>>length;
	cin>>width;
	cin>>height;
	get_area();
	get_volume();
	
}
void Box::area_play()
{
	cout<<"表面积为"<<area<<endl;
}
void Box::volume_play()
{
	cout<<"体积为"<<volume<<endl;
}
int main()
{
	Box b1,b2,b3;
	b1.get_doul();
	cout<<"第一个长方柱:"<<endl;
	b1.area_play();
	b1.volume_play();
	b2.get_doul();
	cout<<"第二个长方柱:"<<endl;
	b2.area_play();
	b2.volume_play();
	b3.get_doul();
	cout<<"第三个长方柱:"<<endl;
	b3.area_play();
	b3.volume_play();
	return 0;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值