/*
* Copyright (c) 2014,烟台大学计算机学院
* All right reserved.
*文件名称:main.cpp
* 作者:王元阳
* 完成时间:2015年3月18日
* 版本号:v1.0
*
*问题描述:编写程序,求3个长方柱的体积
*输入描述:长方柱的长、宽、高
*程序输出:三个长方柱的体积和表面积
*/
#include <iostream>
using namespace std;
class Bluk
{
public:
void get_value();
void display();
private:
double length;
double width;
double heigth;
};
void Bluk::get_value()
{
cout<<"请输入依次长方柱的长,宽,高:";
cin>>length;
cin>>width;
cin>>heigth;
}
void Bluk::display()
{
cout<<"长方柱的体积为:"<<length*width*heigth<<endl;
cout<<"长方柱的表面积为:"<<2*(length*width+length*heigth+width*heigth)<<endl;
}
int main()
{
Bluk b1,b2,b3;
b1.get_value();
cout<<"b1的体积与表面积为:"<<endl;
b1.display();
b2.get_value();
cout<<"b2的体积与表面积为:"<<endl;
b2.display();
b3.get_value();
cout<<"b3的体积与表面积为:"<<endl;
b3.display();
return 0;
}
第2周项目2——长方柱
最新推荐文章于 2016-03-28 22:40:42 发布