#include <iostream>
#include <cmath>
using namespace std;
int main ()
{
const double PI = 3.14159;
double num, area, radius, base, length, width, height;
cout << "Geometry Calculator\n";
cout << " 1. Calculate the Area of a Circle\n";
cout << " 2. Calculate the Area of a Rectangle\n";
cout << " 3. Calculate the Area of a Triangle\n";
cout << " 4. Quit\n\n";
cout << " Enter your choice (1-4): ";
cin >> num;
if (num == 1)
{
cout << "Enter the length of the radius: ";
cin >> radius;
if (radius < 0)
{
cout << "Enter values greater than 0.";
exit (0);
}
else
{
area = PI * pow (radius, 2.0);
cout << "The area of the circle is " << area << " square units.\n";
}
}
else if (num == 2)
{
cout << "Enter the length of the rectangle: ";
cin >> length;
if (length < 0)
{
cout << "Error. Enter values greater than 0.";
exit (0);
}
else
{
cout << "Enter the width of the rectangle: ";
cin >> width;
if (width < 0)
{
cout << "Error. Enter values greater than 0.";
exit (0);
}
else
{
area = length * width;
cout << "The area of the rectangle is " << area <<
" square units.";
}
}
}
else if (num == 3)
{
cout << "Enter the length of the triangle's base: ";
cin >> base;
if (base < 0)
{
cout << "Error. Enter values greater than 0.";
exit (0);
}
else
{
cout << "Enter the triangle's height: ";
cin >> height;
if (height < 0)
{
cout << "Error. Enter values greater than 0.";
exit (0);
}
else
{
area = base * height * 0.5;
cout << "The area of the triangle is " << area <<
" square units.";
}
}
}
else if (num == 4)
{
cout << "Thank you. Goodbye.";
exit (0);
}
}