// Marvyn De La Torre    CS1A    Chapter 4, P.225, #21

/**************************************************************
* Calculate Geometric Area
*
* This program calculates the area of a circle, rectangle, or
* triangle based on the selected geometric shape.
*
* Input:
* Menu selection = choice
* Radius = radius
* Length = length
* Width = width
* Base = base
* Height = height
*
* Output:
* Area = area
**************************************************************/

#include <iostream>
#include <iomanip>
using namespace std;

int main()
{
    int choice;
    double area, radius, length, width, base, height;

    cout << "Geometry Calculator" << endl;
    cout << "1. Calculate the Area of a Circle" << endl;
    cout << "2. Calculate the Area of a Rectangle" << endl;
    cout << "3. Calculate the Area of a Triangle" << endl;
    cout << "4. Quit" << endl;
    cout << "Enter your choice: ";
    cin >> choice;

    cout << fixed << showpoint << setprecision(2);

    switch (choice)
    {
        case 1:
            cout << "Enter the radius: ";
            cin >> radius;

            if (radius < 0)
                cout << "Radius cannot be negative." << endl;
            else
            {
                area = 3.14159 * radius * radius;
                cout << "Area: " << area << endl;
            }
            break;

        case 2:
            cout << "Enter the length: ";
            cin >> length;

            cout << "Enter the width: ";
            cin >> width;

            if (length < 0 || width < 0)
                cout << "Length and width cannot be negative." << endl;
            else
            {
                area = length * width;
                cout << "Area: " << area << endl;
            }
            break;

        case 3:
            cout << "Enter the base: ";
            cin >> base;

            cout << "Enter the height: ";
            cin >> height;

            if (base < 0 || height < 0)
                cout << "Base and height cannot be negative." << endl;
            else
            {
                area = base * height * 0.5;
                cout << "Area: " << area << endl;
            }
            break;

        case 4:
            cout << "Program ended." << endl;
            break;

        default:
            cout << "Invalid choice." << endl;
    }

    return 0;
}