/*
*程序的版权和版本声明部分:
*Copyright(c)2013,烟台大学计算机学院学生
*All rights reserved.
*文件名称:学生成绩统计
*作者:刘中林
*完成日期:2013年 03月16日
*版本号:v0.1
*对任务及求解方法的描述部分:题意
*输入描述:给定
*问题描述: 表面积、体积
*程序输出:计算后的表面积、体积
*问题分析:算法
*算法设计:areas=2*(length*width+length*height+width*height); volume=length*width*height
*我的程序:
*/
#include <iostream>
using namespace std;
class Bulk
{
public:
void get_value();
void display();
private:
void get_volume();
void get_areas();
float length;
float width;
float height;
float volume;
float areas;
};
void Bulk::get_value()
{
cout<<"请分别输入长宽高:";
cin>>length;
cin>>width;
cin>>height;
get_volume();
get_areas();
}
void Bulk::get_areas()
{
areas=2*(length*width+length*height+width*height);
}
void Bulk::get_volume()
{
volume=length*width*height;
}
void Bulk::display()
{
cout<<"表面积为:"<<areas<<endl;
cout<<"体积为:"<<volume<<endl;
}
int main()
{
Bulk b1,b2,b3;
b1.get_value();
cout<<"第一个长方柱:"<<endl;
b1.display();
b2.get_value();
cout<<"第二个长方柱:"<<endl;
b2.display();
b3.get_value();
cout<<"第三个长方柱:"<<endl;
b3.display();
return 0;
}
*样例输出:
*心得体会:DEV c++做的。。