第三周项目4-长方柱类

来源:互联网 发布:java控制面板 编辑:程序博客网 时间:2024/05/09 20:51
/** Copyright (c) 2012, 烟台大学计算机学院 * All rights reserved. * 作    者:尹成真* 完成日期:2013年 3月20日 * 版 本 号:v1.0 * 输入描述: 在类声明中声明成员函数* 问题描述:略* 程序输出:长方柱的体积和表面积* 算法设计:*/#include <iostream>  using namespace std;  class Box  {  public:      void get_value();      void get_display();  private:  void get_volume();        void get_surface();      float lengh;      float width;      float height;  float volume;float surface;};  void Box::get_value()  {       cout<<"请输入长,宽,高:";      cin>>lengh;      cin>>width;      cin>>height;      get_volume();        get_surface();  }  void Box::get_volume()  {  volume=lengh*width*height;  }  void Box::get_surface()  {      surface=2*(lengh*width+lengh*height+width*height);  }  void Box::get_display()  {       cout<<"The volume is: "<<volume<<endl;      cout<<"The surface  is: "<<surface<<endl;  }  int main()  {      Box b1,b2,b3;      b1.get_value();      cout<<"For box1: "<<endl;      b1.get_display();      b2.get_value();      cout<<"For box2: "<<endl;      b2.get_display();      b3.get_value();      cout<<"For box3: "<<endl;      b3.get_display();      return 0;  }  

放上去的截图怎么看不到啊

原创粉丝点击