#1462. 类练习-求3个长方体的体积

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

Description

 

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

Input Format

主函数为:
 
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

Source

未分类