#include <iostream>
#include <string>
using namespace std;
int square (int l, int w);
double triangle (double h, double b);
double circle (double r);
int main()
{
double height ,base ,radius , triangle_area , circle_area ;
int length, width;
string a;
do {
cout<<" Hello, I will help you with common math formulas ";
cout << "1.square.";
cout << "2.triangles.";
cout << "3.circle";
cout << ">> ";
int choice;
cin >> choice;
switch(choice){
case 1:
cout << "Enter the length of the square: ";
cin >> length;
cout << "Enter the width of the square: ";
cin >> width;
int area;
area= square(length, width);
cout << "The area of the square is " << area << endl;
break;
case 2:
cout << "Enter the height of the triangle: ";
cin >> height ;
cout << "Enter the base of the triangle: ";
cin >> base ;
triangle_area = triangle(height, base);
cout << "The area of the triangle is " << triangle_area << endl;
break;
case 3:
cout << "Enter the circle: ";
cin >> radius;
circle_area = circle (radius);
cout << "The area of the circle is " << circle_area << endl;
break;
default:
cout << "Wrong choice, you have to enter a number between 1 and 3" << endl;
break;
cout << "Would you like to exit? (yes/no): ";
cin >> a;
}
while ((a == "no") || (a == "n"));
return 0;
}
}
int square (int l, int w)
{
return l * w;
}
double triangle (double h, double b)
{
return h * b* 0.5;
}
double circle (double r)
{
return 3.14159 * (r * r);
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0cmluZz4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKaW50IHNxdWFyZSAoaW50IGwsIGludCB3KTsKZG91YmxlIHRyaWFuZ2xlIChkb3VibGUgaCwgZG91YmxlIGIpOwpkb3VibGUgY2lyY2xlIChkb3VibGUgcik7CmludCBtYWluKCkKewoJCglkb3VibGUgaGVpZ2h0ICxiYXNlICxyYWRpdXMgLCB0cmlhbmdsZV9hcmVhICwgY2lyY2xlX2FyZWEgOwoJaW50IGxlbmd0aCwgd2lkdGg7CglzdHJpbmcgYTsKCQlkbyB7CgkJY291dDw8IiBIZWxsbywgSSB3aWxsIGhlbHAgeW91IHdpdGggY29tbW9uIG1hdGggZm9ybXVsYXMgIjsKCQljb3V0IDw8ICIxLnNxdWFyZS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50ZXIgdGhlIGNpcmNsZTogIjsKICAgICAgICAgICAgICAgY2luID4+IHJhZGl1czsKCSAgICAgICBjaXJjbGVfYXJlYSA9IGNpcmNsZSAocmFkaXVzKTsKY291dCA8PCAiVGhlIGFyZWEgb2YgdGhlIGNpcmNsZSBpcyAiIDw8IGNpcmNsZV9hcmVhIDw8IGVuZGw7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIAogICAgICAgICAgICBkZWZhdWx0OgogICBjb3V0IDw8ICJXcm9uZyBjaG9pY2UsIHlvdSBoYXZlIHRvIGVudGVyIGEgbnVtYmVyIGJldHdlZW4gMSBhbmQgMyIgPDwgZW5kbDsKICAgICAgICAgICAgICAgICAgICBicmVhazsKCQoJY291dCA8PCAiV291bGQgeW91IGxpa2UgdG8gZXhpdD8gKHllcy9ubyk6ICI7CiAgICAgICAgICAgICAgICAgICAgIGNpbiA+PiBhOwoJICAgICAgICAgfQogICAgICAgICAgICAgICB3aGlsZSAoKGEgPT0gIm5vIikgfHwgKGEgPT0gIm4iKSk7CgkJICByZXR1cm4gMDsKICAgICAgICAgICAgICAgICAgfQp9CiAgICAgIAogaW50IHNxdWFyZSAoaW50IGwsIGludCB3KQp7CnJldHVybiBsICogdzsKfQpkb3VibGUgdHJpYW5nbGUgKGRvdWJsZSBoLCBkb3VibGUgYikKewpyZXR1cm4gaCAqIGIqIDAuNTsKfQpkb3VibGUgY2lyY2xlIChkb3VibGUgcikKewpyZXR1cm4gMy4xNDE1OSAqIChyICogcik7Cn0=