//Cecilia Rangel CSC5 Chapter 4, P. 225, #21
//
/**************************************************************
 *
 * Computing geometry calculator
 * ____________________________________________________________
 * This program computes the area of specific shapes
 * 
 *
 * Computation is based on the following formulas:
 * Area of Circle = PI * (Radius)^2
 * Area of Rectangle = Length * Width
 * Area of Triangle = Base * Height * .5
 *___________________________________________________________
 * CONSTANTS
 * 		PI                  : Value of pi to 5 decimal places (3.14159)
 * 		Circle choice       : Menu option for a circle
 * 		Rectangle choice    : Menu option for a rectangle
 * 		Triangle choice     : Menu option for a triangle
 *	 	Quit choice         : Menu option for exiting the program immediately
 *
 * INPUT
 * 		choice              : Integer expression for choosing menu option
 *		radius              : Measurement of circle's radius
 *		length              : Measurement of rectangle's length
 *		width               : Measurement of rectangle's width
 *		base                : Measurement of triangle's base
 *		height              : Measurement of triangles height
 *	
 * OUTPUT
 *		display		  : which number is greater
 *
 **************************************************************/
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main() {
	const double PI = 3.14159;        
	const int CIRCLE_CHOICE = 1;      
	const int RECTANGLE_CHOICE = 2;   
	const int TRIANGLE_CHOICE = 3;    
	const int QUIT_CHOICE = 4;       
	                               
 
	int choice;			
	double radius;     
	double length;     
	double width;       
	double base;       
	double height;      
	double area;        

	cout << "Geometry Calculator" << endl << 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 << endl;
	cout << "    Enter your choice (1-4): ";
	cin >> choice;
	cout << endl << endl;

	cout << left;
	switch (choice)
	{
		case CIRCLE_CHOICE:
			cout << "1. AREA OF A CIRCLE:" << endl;
			cout << setw(14) << "Enter radius: ";
			cin >> radius;
			if (radius > 0)
			{
				area = PI * pow(radius, 2);
				cout << endl;
				cout << setw(14) << "Area: " << area;
			}
			else
				cout << "Radius must be positive! Run program again.";
			break;
		case RECTANGLE_CHOICE:
			cout << "2. AREA OF A RECTANGLE:" << endl;
			cout << setw(14) << "Enter length: ";
			cin >> length;
			cout << setw(14) << "Enter width: ";
			cin >> width;
			if (length > 0 && width > 0)
			{
				area = length * width;
				cout << endl;
				cout << setw(14) << "Area: " << area;
			}
			else
				cout << "Length & width must be positive! Run program again.";
			break;
		case TRIANGLE_CHOICE:
			cout << "3. AREA OF A TRIANGLE:" << endl;
			cout << setw(19) << "Enter base length: ";
			cin >> base;
			cout << setw(19) << "Enter height: ";
			cin >> height;
			if (base > 0 && height > 0)
			{
				area = base * height * .5;
				cout << endl;
				cout << setw(19) << "Area: " << area;
			}
			else
				cout << "Base & height must be positive! Run program again.";
			break;
		case QUIT_CHOICE:
			break;
		default:
			cout << "Your choice must a number from 1-4! Run program again.";
	}
	cout << right;
	return 0;
}