I just need some help with an UML for this program.
#include <iostream>
#include <math.h>
#include <iostream>
#include<iomanip>
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 << “<Andres Padilla>” << 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;
}