Question: Program 5 Rectangle - Complete the following code then run it - Produce the correct output and Turn it in for credit // classes example

Program 5 Rectangle - Complete the following code

then run it - Produce the correct output and Turn it in for credit

// classes example #include  using namespace std; class Rectangle { int width, height; public: void set_values (int,int); int area() { int answer; // complete this function so the code works return answer; } }; void Rectangle::set_values (int x, int y) { // complete this function so the code works } int main () { // Use this driver program 
 // Use set_values function to set values Rectangle rect1; rect1.set_values (5,6); cout << "area: " << rect1.area() << endl; 
// Use set_values function to set values Rectangle rect2; rect2.set_values (3,4); cout << "area: " << rect2.area() << endl; return 0; } 

-------------------------------------------------------------

 

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;

}

-----------------------------------------------------------------------------

Program 7 - Circle

You write ALL the code,

then run it - Produce the correct output. Turn in code and screen print of successful run, for credit

* Write a class for a Circle

* Input only the radius.

* Write functions that Calculate the circles Circumference, Area and Diameter, and print out the value of the radius

* Include error checking for radius, must be greater than zero

made into template classes C++

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!