Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program 6 BOX - Complete the following code then run it - Produce the correct output and Turn it in for credit - Note: A

Program 6 BOX - Complete the following code then run it - Produce the correct output and Turn it in for credit - Note: A Box is a 3D object... Write a class for a BOX (box is another name for a cube) It should contain: Width, Height, and Depth It should contain 3 methods to input/set the Width, Height, and Depth Values. It should contain a method to calculate the Volume of the box. It should contain a method to calculate sum of the Area the 6 sides of the box,. It should contain three method to return/get the individual values of the Width, Height and Depth variables in the class All dimensions must be greater than zero, before the area or volume can be calculate... the calc functions should cout an error message is they are not.

Test the box with the following driver code: HINT: Use function names and class name found in driver below.

int main() { // Box 1 - Test set functions, Volume, getHeight and area functions box B1;

// HINT MAKE A Default constructor or set functions...

B1.setWidth(2);

B1.setHeight(3);

B1.setDepth(4);

cout << "Height = " << B1.getHeight << endl;

cout << "Area = " << B1.calcArea() << endl;

cout << "Volume = " << B1.calcVolume() << endl;

// Box 2 - Test zero value error for calc Area and Volume of sides functions box B2;

B2.setWidth(3);

B2.setHeight(4);

cout << "Depth = " << B2.getDepth << endl;

cout << "Area = " << B2.calcArea() << endl;

cout << "Volume = " << B2.calcVolume() << endl;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Factory Active Database For Enterprise Computing

Authors: Schur, Stephen

1st Edition

0471558443, 9780471558446

More Books

Students also viewed these Databases questions