//Matthew Santos CS1A Ch. 4, Pg. 225, #21
/***********************************************
*
* CALCULATE AREAS
* _____________________________________________
* DESCRIPTION
* From a selection of different shapes, calculates
* the area of that selected shape.
* _____________________________________________
* INPUT
* length: length of rectangle
* width: width of rectangle
* radius: radius of circle
* base: width of base of triangle
* height: height of triangle
*
* OUTPUT
* areaR: area of the rectangle
* areaC: area of the circle
* areaT: area of the triangle
***********************************************/
#include <iostream>
using namespace std;
int main() {
//Initialize variables
float length;
float width;
float radius;
float base;
float height;
int choice;
float areaR;
float areaC;
float areaT;
//Display menu
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;
//Choose
cin >> choice;
//Output according to choice
switch (choice){
case 1:
cout << "Enter radius" << endl;
cin >> radius;
areaC = 3.14159 * (radius * radius);
cout << areaC;
break;
case 2:
cout << "Enter length and width" << endl;
cin >> length;
cin >> width;
areaR = length * width;
cout << areaR;
break;
case 3:
cout << "Enter base and height" << endl;
cin >> base;
cin >> height;
areaT = base * height * .5;
cout << areaT;
break;
case 4:
break;
}
return 0;
}