Question: Hello! I was assingned to write a program that contains the following Dynamic memory allocation Classes with static and/or instance data fields and functions as
Hello! I was assingned to write a program that contains the following
Dynamic memory allocation Classes with static and/or instance data fields and functions as private and/or public. UML diagrams are required. Pointer usages
. I need help to the Dynamic memory allocation Classes with static and/or instance data fields and functions as private and/or public. UML diagrams are required. Pointer usages
///// And this I what I have in my code so far.
#include
} // If the radius is greater than 0 calculate the area if ( radius >= 0 ) { double area = pow (radius, 2 ) * PI; cout << "Area of the circle is " << area << endl; } } void Option_2() { // Promt user to enter a side cout << "Enter side: "; // Declare side int side; cin >> side; // If the side is less than 0 display a message if ( side < 0 ) {
cout << "Invalid side " << endl; } // If the side is greater than 0 calculate the area if ( side > 0) { cout << "Area of the square is " << side * side << endl; } } void Option_3() { // // Promt user to enter length and width cout << "Enter length and width: "; // Declare length and width double length, width ; cin >> length >> width; // If the length is less than 0 display a message if ( length < 0 ) { cout << "Invalid length " << endl; } // If the width is less than 0 display a message if ( width < 0 ) { cout << "Invalid width " << endl;
} // If the length and width are greater than 0 calculate the area if ( length >= 0 && width >= 0 ) { double area = length * width; cout << "Area of the rectangle is " << area << endl; } } int main() { while(true) { // Menu option system("cls"); cout << endl; cout << "
{ case 1: Option_1(); break; case 2: Option_2(); break; case 3: Option_3(); break; default: exit(0); } cout << endl; system("pause"); cin.clear(); } return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
