1981: 类练习-求3个长方体的体积

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:5 通过:5

题目描述

 

§需要求3个长方体的体积,请编写一个基于对象的程序。对象的数据成员包括length,width,height。要求用成员函数实现以下功能:
1)由键盘分别输入3个长方体的长、宽、高;
2)计算长方体的体积;
3)输出3个长方体的体积。

输入格式

主函数为:
 
int main()
{
  Box box1,box2,box3; //类名定义为Box
  box1.get_value();
  cout <<"volmue of box1 is ";
  box1.display();
  box2.get_value();
  cout <<"volmue of box2 is ";
  box2.display();
  box3.get_value();
  cout <<"volmue of box3 is ";
  box3.display();
  return 0;
}
 

输入样例 复制

3 4 5
5 6 7
8 9 10

输出样例 复制

volmue of box1 is 60
volmue of box2 is 210
volmue of box3 is 720