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 #include using namespace std; // Declare pi const double PI = 3.14159; // Declare option 1 void Option_1() { // Prompt user to enter a radius cout << "Enter radius: "; double radius; cin >> radius; // If the radius is less than 0 display a message if ( radius < 0 ) { cout << "Invalid radius; " << endl;

} // 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 << "" << endl; cout << endl; cout << "Extra Credit - Calculate-Area " << endl; cout << "================================= " << endl; cout << " " << " 1: Circle " << endl; cout << " " << " 2: Square " << endl; cout << " " << " 3: Rectangle " << endl; cout << "Other: Exit " << endl; cout << "================================= " << endl; // Prompt user to choose an option cout << "Enter option: "; char option[2]; cin >> option; switch (atoi(option))

{ 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

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!