#include #include using namespace std; // function prototypes void errorRadius(); void errorRectangle(); void errorTriangle(); void showMenu(); double getRadius(); void successfulTerminationOfProgramMessage(); void errorInvalidMenuOption(); double areaCircle(double); double areaRectangle(double, double); double areaTriangle( double, double); bool validRadius(double); bool validLengthAndWidth(double, double); bool validBaseAndHeight(double, double); // My Geometry Calculator int main() { int selection; double radius, length, width, base, height; do{ // display the Geometry Calculator menu showMenu(); cin>>selection; // Get the user's selection cout<>length; // get length cout<<"\t\tEnter width: "; cin>>width; // get width areaRectangle(length, width); // call areaRectangle function // if the length or width is negative display error message, if not then display the rectangles's area if (validLengthAndWidth(length, width)) { errorRectangle(); } else { cout<<"\t\tArea = " <>base; // get base cout<<"\t\tEnter height: "; cin>>height; // get height areaTriangle(base, height); // if the base or height is negative display error message, if not then display the triangle's area if (validBaseAndHeight(base, height)) { errorTriangle(); } else { cout<<"\t\tArea = " <>rad; return rad; } void successfulTerminationOfProgramMessage() { cout<<"\n\t\tThank you for using the Geometry Calculator\n"; } void errorInvalidMenuOption() { cout<<"\n\t\t**Error: Menu option must be 1, 2, 3, or 4\n"; cout<<"\n\t\t~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\n"; } double areaCircle(double num1) { const double PI = 3.14159; double result; result = (num1 * num1) * PI; return result; } double areaRectangle(double num2, double num3) { double product; product = num2 * num3; return product; } double areaTriangle(double number1, double number2) { double product; product = (number1 * number2) * 0.5; return product; } bool validRadius(double number) { bool status; if(number < 0) status = true; else status = false; return status; } bool validLengthAndWidth(double number1, double number2) { bool status; if (number1 < 0 || number2 < 0) status = true; else status = false; return status; } bool validBaseAndHeight(double a, double b) { bool status; if (a < 0 || b < 0) status = true; else status = false; return 0; }