/*
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:
求长方体的体积和表面积
最新推荐文章于 2023-08-15 14:07:57 发布