您的位置:首页 > 其它

求长方体的体积和表面积

2016-05-08 21:21 423 查看
/*

2.

3. *Copyright   (c)  2016,烟台大学计算机学院

4.

5. *All rights reserved.

6.

7. *文件名称:test.cpp

8.

9. *作者: 武聪

10.

11. *完成日期:2016年5月8日

12.

13. *版本号:v1.0

14. *问题描述:求长方柱的体积和面积

15. *输入描述:长宽高

16. *程序输出:体积和表面积

17. */

#include <iostream>
using namespace std;
class Bulk
{
public:
void get_value();
void display();
private:
float lengh;
float width;
float height;
};

void Bulk::get_value()
{
cout<<"please input lengh, width,height:";
cin>>lengh;
cin>>width;
cin>>height;
}

void Bulk::display()
{
cout<<"The volume is: "<<lengh*width*height<<endl;
cout<<"The surface area is: "<<2*(lengh*width+lengh*height+width*height)<<endl;
}

int main()
{
Bulk b1,b2,b3;

b1.get_value();
cout<<"For bulk1: "<<endl;
b1.display();

b2.get_value();
cout<<"For bulk2: "<<endl;
b2.display();

b3.get_value();
cout<<"For bulk3: "<<endl;
b3.display();
return 0;
}


运行结果:



知识点总结:

函数的使用

学习心得:

要更加努力
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: