What is the incorrect action and why does it occur?

Specification: The following program should set the dimensions of a Cube object to 3 and calculate the volume and surface area.
```
#include
#include
using namespace std;
class Cube
{
private:
float side;
public:
Cube() { side = 0.0; }
void SetSide(float s) {side = s; }
float Volume(){ return pow(side,2); }
float SurArea() { return 8.0 * side*side; }
};
int main()
{
Cube MyCube;
float CubeVol, CubeSA;
MyCube.SetSide(5);
CubeVol = MyCube.Volume();
CubeSA = MyCube.SurArea();
return 0;
}
```


This program has an incorrect value passed to the SetSide function. The SetSide function call is using the value of 5 instead of 3.

There are two calculation errors in this program.

The Volume function should be using a cubic function instead of a square function. (The volume of a cube is side*side*side.)

A cube has six sides, not eight; so the SurArea function should be
6.0 * side * side

Computer Science & Information Technology

You might also like to view...

Which resource is a physical asset?

A. Web site B. Computer system C. Data D. Information

Computer Science & Information Technology

A feature that shows what applying a format change would do to the document before you actually make the selection is called ________

A) Protected view B) Live Preview C) ScreenTip D) KeyTip

Computer Science & Information Technology

A ____ is approximately one million bytes.

A. kilobyte B. megabyte C. gigabyte D. terabyte

Computer Science & Information Technology

Which of the following is a drawback of the bring your own device (BYOD)business policy?

a. It affects the productivity of the employees of a company. b. It inhibits the privacy of the employees of a company. c. It exposes a company’s data to malware. d. It creates the image of a company as not being flexible.

Computer Science & Information Technology