/*******************************************************************************
* calculate area of circle/rectangle/triangle
*_______________________________________________________________________________
*calculates area of a shape chosen by input
*_______________________________________________________________________________
*INPUT
* if 1 (area of circle), radius
* if 2 (area of rectangle), length, width
* if 3 (area of triangle), base, height
* if 4, quit
*OUTPUT (AREA)
* if 1, pi * radius * radius
* if 2, length * width
* if 3, (base * height) * 0.5
* if 4, "goodbye"
*******************************************************************************/
#include <iostream>
using namespace std;
int main() {
int choice;
double radius;
double length;
double width;
double base;
double height;
double area;
const double pi = 3.14159;
cout << "choose the shape you want to calculate the area of\n";
cout << "1. circle\n" << "2. rectangle\n" << "3. triangle\n" << "4. quit\n";
cin >> choice;
if (choice==1) {
cout << " \n" << "you have selected circle\n" << "enter radius\n";
cin >> radius;
if (radius < 0) {
cout << "radius can not be negative.\n";
} else {
area = radius * radius * pi;
cout << "area = " << area << endl;
}
} else if (choice==2) {
cout << " \n" << "you have selected rectangle\n";
cout << "enter length\n";
cin >> length;
cout << "enter width\n";
cin >> width;
cin >> radius;
if (length < 0 || width < 0) {
cout << "length and width can not be negatives.\n";
} else {
area = length * width;
cout << "area = " << area << endl;
}
} else if (choice==3) {
cout << " \n" << "you have selected triangle\n";
cout << "enter base\n";
cin >> base;
cout << "enter height\n";
cin >> height;
if (base < 0 || height < 0) {
cout << "base and height can not be negatives.\n";
} else {
area = base * height * 0.5;
cout << "area = " << area << endl;
}
} else if (choice==4) {
cout << " \n"<< "you decided to quit, goodbye!\n";
}
return 0;
}