您的位置:首页 > 其它

2013第三周上机任务【项目三 长方体类】

2013-03-18 10:33 330 查看
/*
* Copyright (c) 2013, 烟台大学计算机学院
* All rights reserved.
* 文件名称:test.cpp
* 作者:樊露露
* 完成日期:2013 年 3 月 18 日
* 版本号:v1.0
*
* 输入描述:无
* 问题描述:
* 程序输出:
* 问题分析:
* 算法设计:略
*/
#include<iostream>
using namespace std;
class Block{
public:
void set_date();
void volume();//体积
void areas();//表面积
private:
float length;
float width;
float heigth;
};
void Block::set_date(){
cout<<"请依次输入长方体的长、宽、高:";
cin>>length>>width>>heigth;
}
void Block::volume(){
float V;
V=length*width*heigth;
cout<<"此长方体的体积为 "<<V<<"。"<<endl;
}
void Block::areas(){
float S;
S=2*(length*width+width*heigth+length*heigth);
cout<<"此长方体的表面积为 "<<S<<"。"<<endl;
}
int main(){
Block block;
cout<<"第一个长方体"<<endl;
block.set_date();
block.volume();
block.areas();
cout<<"第二个长方体"<<endl;
block.set_date();
block.volume();
block.areas();
cout<<"第三个长方体"<<endl;
block.set_date();
block.volume();
block.areas();
return 0;
}


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: