//Andres Guzman CSC5 Chapter 4, P. 225, #21
//
/**************************************************************
*
* SELECT CALCULATION OPTION
* ____________________________________________________________
* This program will allow the user to select an option to calculate.
*
* Computation is based on the formula:
* area1 = pi * pow(radius,2)
* area2 = length * width
* area3 = length * height
* ____________________________________________________________
* INPUT
* radius = Input the radius for an object
* length = Input the desired length of an object
* width = Input desired width of an object
* height = Input desired height for an object
* OUTPUT
* area1 = The area of a circle
* area2 = The area of a rectangle
* area3 = The area of a triangle
*
**************************************************************/
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
//
//Initlaizing Variabales
int choice; //Holds the input for the choices
double area1, area2, area3; //Holds room for different areas of calculation
double pi = 3.14159; //Holds a fraction of pi
double radius, length, width, height; //Holds the different input measurements
const int CIR_AREA = 1; //Option 1 for the circle
const int REC_AREA = 2; //Option 2 for the rectangle
const int TRI_AREA = 3; //Option 3 for the triangle
const int QUIT = 4; //Option to end program
//
//Output Options
cout << "\t\Geometry Calculator\n\n"
<< "1. Calculate the Area of a Circle\n"
<< "2. Calculate the Area of a Rectangle\n"
<< "3. Calculate the Area of a Triangle\n"
<< "4. Quit\n"
<< "Enter your choice (1-4): ";
cin >> choice;
//
//Initialize option selection
switch(choice)
{
case 1 : cout << "\nWhat is the radius of the circle? ";
cin >> radius;
area1 = pi * pow(radius,2); //Calculates area of circle
cout << "\nArea: " << area1;
break;
case 2 : cout << "\nWhat is the length of the rectangle? ";
cin >> length;
cout << "\nWhat is the width of the rectangle? ";
cin >> width;
area2 = length * width; //calculates the area of a rectangle
cout << "\nArea: " << area2;
break;
case 3 : cout << "\nWhat is length of the Triangle? ";
cin >> length;
cout << "\nWhat is the height of the Triangle? ";
cin >> height;
area3 = length * height * .5; //calculates the area of a triangle
cout << "\nArea: " << area3;
break;
case 4 : cout << "\nTerminating Program.";
break;
default : cout << "\nInvalid input. Please input 1, 2, 3, or 4.";
break;
}
return 0;
}