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
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started