第三周项目四-长方柱类
2014-03-13 23:12
204 查看
#include <iostream> using namespace std; class Bulk { public: void set(); void c_volume(); void c_areas(); private: double length; double width; double heigth; }; void Bulk::set() { double l,w,h; cout<<"请分别输入长、宽、高:"; cin>>l>>w>>h; length=l; width=w; heigth=h; } void Bulk::c_volume() { double v; v=length*width*heigth; cout<<"体积为:"<<v<<endl; } void Bulk::c_areas() { double a; a=(length*width+length*heigth+width*heigth)*2; cout<<"表面积为:"<<a<<endl; } int main() { Bulk x,y,z; x.set(); y.set(); z.set(); x.c_volume(); x.c_areas(); y.c_volume(); y.c_areas(); z.c_volume(); z.c_areas(); return 0; }
运行结果:
相关文章推荐
- 第三周项目4-长方柱类
- 第二学期第三周项目4--长方柱类
- 第三周 项目三:用对象数组操作长方柱类
- 第三周项目3——用数组对象操作长方柱类
- 第三周(项目四)——长方柱类。
- 第三周 项目四:长方柱类
- 第三周 项目4-长方柱类
- 第三周上机任务项目4-长方柱类
- 第三周项目4-长方柱类
- 第三周项目4长方柱类
- 第三周-项目4——长方柱类
- 第三周项目4-长方柱类
- 第三周项目2 - 建设“顺序表”算法库
- 第三周项目 2 测试与设计
- 第三周 项目1—顺序表的基本运算(3)
- 第三周项目1-顺序表的基本运算
- 第三周项目1--顺序表的基本运算
- 第三周项目2
- 第三周项目4-顺序表应用 删除【x,z】之间的元素
- 第三周项目1 顺序表的基本运算