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