Fill Water

#include <iostream>
using namespace std;
class Box
  {
    double width,height,depth;
  public:
    Box()
     {
      width=0;
      height=0;
      depth=0;
     }
    Box(double w, double h, double d)
     {
       width=w;
       height=h;
       depth=d;
     }
  double volume()
    {
      return width*height*depth;
    }
  };
   
int main()
{
    Box mybox1;
    double a,vol;
    cout<<mybox1.volume()<<endl;
    //cout<<value<<endl;
    cin>>a;
    Box mybox2(a,a,a);
    vol = mybox2.volume();
    cout<<vol;
return 0;
}

7 comments:

  1. change "Box(double w, double h, double d)"
    to "Box(double w,double h,double d)"

    for 100% result

    ReplyDelete
  2. //This code is working

    #include
    using namespace std;
    class Box
    {
    double width, height, depth;

    public:
    Box()
    {
    width = 0;
    height = 0;
    depth = 0;
    }
    Box(double samevalue)
    {
    width = samevalue;
    height = samevalue;
    depth = samevalue;
    }
    double volume()
    {
    return width * height * depth;
    }
    };
    int main()
    {
    Box mybox1;
    double a, vol;
    cout << mybox1.volume() << endl;
    cin >> a;
    Box mybox2(a);
    vol = mybox2.volume();
    cout << vol;
    return 0;
    }

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. #include
    using namespace std;
    class Box
    {
    double width,height,depth;
    public:
    Box(double samevalue)
    {
    width=0;
    height=0;
    depth=0;
    }
    Box(double w, double h, double d)
    {
    width=w;
    height=h;
    depth=d;
    }
    double volume()
    {
    return width*height*depth;
    }
    };

    int main()
    {

    double a,vol;
    cin>>a;
    Box mybox1(a);
    cout<<mybox1.volume()<<endl;
    Box mybox2(a,a,a);
    vol = mybox2.volume();
    cout<<vol;
    return 0;
    }

    ReplyDelete