Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I just need some help with an UML for this program. #include #include #include #include using namespace std; // Declare pi const double PI =

I just need some help with an UML for this program.

#include #include #include #include using namespace std; // Declare pi const double PI = 3.14159; // Declare option 1 class Area{ //Declared Class. public: void Option_1(); void Option_2(); void Option_3(); };

void Area::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 Area::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 Area::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"); Area s; //Object of Area 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 = (char *)malloc(2*sizeof(char)); //Dynamical Memory allocation cin >> option; switch (atoi(option)) { case 1: s.Option_1(); break; case 2: s.Option_2(); break; case 3: s.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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Securing SQL Server Protecting Your Database From Attackers

Authors: Denny Cherry

2nd Edition

1597499471, 978-1597499477

More Books

Students also viewed these Databases questions

Question

x-3+1, x23 Let f(x) = -*+3, * Answered: 1 week ago

Answered: 1 week ago