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
You might also like to view...
A Panel is used to:
a) group or store components b) display text c) create a border around components d) add style to a form
5. Make a bulleted list of any usability concerns Ashley might have with the interfaces you designed.
What will be an ideal response?