/* * 程序的版权和版本声明部分 * Copyright (c)2013, 烟台大学计算机学院学生 * All rightsreserved. * 文件名称:meiju .cpp * 作 者: 李洋 * 完成日期:2013年3月16日 * 版本号: v1.0 * 输入描述: * 问题描述: */ #include <iostream> using namespace std; class Box {public: float length; float width; float heigth; void get_value(); float volume(); float areas(); }; void Box::get_value() { cout<<"请输入长方柱的长、宽、高:"<<endl; cin>>length; cin>>width; cin>>heigth; } float Box::volume() { return (length*width*heigth); } float Box::areas() { return ((length*width+width*heigth+length*heigth)*2); } int main() { Box box1,box2,box3; box1.get_value(); cout<<"此长方柱的体积是:"<<endl; cout<<box1.volume()<<endl; cout<<"此长方柱的表面积是:"<<endl; cout<<box1.areas()<<endl; box2.get_value(); cout<<"此长方柱的体积是:"<<endl; cout<<box2.volume()<<endl; cout<<"此长方柱的表面积是:"<<endl; cout<<box2.areas()<<endl; box3.get_value(); cout<<"此长方柱的体积是:"<<endl; cout<<box3.volume()<<endl; cout<<"此长方柱的表面积是:"<<endl; cout<<box3.areas()<<endl; return 0; }