Im into the last stages of my C++ class and am having trouble with a project that has been assigned. Here is the problem and thanks in advance for whoever helps out!
Declare an object of type bucket
1). Use the SetGallonSize() method to set the bucket size to 5.0 gallons
2). Use the FillBucket() method to fill the bucket to 3.2 gallons of water
3). Use the GetWeight() method to output the weight of the 3.2 gallons of water
Here is the header file that was provided
// bucket.h
#ifndef _BUCKET_H
#define _BUCKET_H
const double WEIGHT_OF_WATER = 8.3;
class bucket
{
public:
// constructors
bucket();
bucket(bucket & Object);
// member functions
void SetGallonSize(double Size);
void FillBucket(double Amount);
double GetWeight();
private:
// data
double MySize,
MyAmount;
};
bucket::bucket()
{
MySize = 0;
MyAmount = 0;
}
bucket::bucket(bucket & Object)
{
MySize = Object.MySize;
MyAmount = Object.MyAmount;
}
void bucket::SetGallonSize(double Size)
{
MySize = Size;
}
void bucket::FillBucket(double Amount)
{
if(Amount <= MySize)
{
MyAmount = Amount;
}
else
{
MyAmount = MySize;
}
}
double bucket::GetWeight()
{
return(MyAmount*WEIGHT_OF_WATER);
}
#endif
Here is my code I have so far. I dont know if Im on the right track, because the output is 53.20.
// bucket.cpp
#include <iostream>
#include <bucket.h>
using namespace std;
int main ()
{
bucket Bucket_Size;
bucket Bucket_Amount;
double MySize = 5.0;
double MyAmount = 3.2;
Bucket_Size.SetGallonSize(MySize);
Bucket_Amount.FillBucket (MyAmount);
cout << "The bucket amount is " << MySize << MyAmount << Bucket_Size.GetWeight() << endl << endl;
return 0;
}