Question: So this program runs but the calculation is way off. The goal is to Design and implement a class box with three private variables length,

So this program runs but the calculation is way off. The goal is to Design and implement a class box with three private variables length, width, and height and member functions to set length set height set width calculate volume In your main program, declare and test functions for objects smallBox and largeBox of class boxType. I'm not sure how to declare and test functions for objects smallBox and largeBox of class boxType. Here is my program so far:

#include #include

using namespace std;

class boxType { private: int length;

int width;

int height;

int volume;

public: void setLength(int alength) { length = alength; } int getLength() { return length; } void setWidth(int awidth) { width = awidth; } int getWidth() { return width; } void setHeight(int aheight) { height = aheight; } int getHeight() { return height; } void setVolume(int Vol) { volume = Vol; } int getVolume() { return volume; }

void calcVolume(int aVol) { volume = length * width * height; } };

int main() { boxType box;

box.setLength(2);

box.setWidth(2);

box.setHeight(2);

box.getVolume();

cout << " The volume for the calculated parameters that are preset in the code is: " << box.getVolume() << " cubic centimeters." << endl;

return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!