#include <iostream>
#include <cmath>
using namespace std;
void square() {
double side;
cout << "Enter the side length of the square: ";
cin >> side;
cout << "Area: " << side * side << ", Circumference: " << 4 * side << endl;
}
void circle() {
double radius;
cout << "Enter the radius of the circle: ";
cin >> radius;
cout << "Area: " << M_PI * radius * radius << ", Circumference: " << 2 * M_PI * radius << endl;
}
void triangle() {
double base, height, side1, side2;
cout << "Enter the base of the triangle: ";
cin >> base;
cout << "Enter the height of the triangle: ";
cin >> height;
cout << "Enter the first side of the triangle: ";
cin >> side1;
cout << "Enter the second side of the triangle: ";
cin >> side2;
cout << "Area: " << 0.5 * base * height << ", Circumference: " << base + side1 + side2 << endl;
}
void cube() {
double side;
cout << "Enter the side length of the cube: ";
cin >> side;
cout << "Volume: " << pow(side, 3) << ", Surface Area: " << 6 * pow(side, 2) << endl;
}
void sphere() {
double radius;
cout << "Enter the radius of the sphere: ";
cin >> radius;
cout << "Volume: " << (4.0 / 3.0) * M_PI * pow(radius, 3) << ", Surface Area: " << 4 * M_PI * pow(radius, 2) << endl;
}
void pyramid() {
double base_length, base_width, height;
cout << "Enter the base length of the pyramid: ";
cin >> base_length;
cout << "Enter the base width of the pyramid: ";
cin >> base_width;
cout << "Enter the height of the pyramid: ";
cin >> height;
double volume = (1.0 / 3.0) * base_length * base_width * height;
double surface_area = base_length * base_width + base_length * height + base_width * height;
cout << "Volume: " << volume << ", Surface Area: " << surface_area << endl;
}
void cone() {
double radius, height;
cout << "Enter the radius of the cone: ";
cin >> radius;
cout << "Enter the height of the cone: ";
cin >> height;
double slant_height = sqrt(pow(radius, 2) + pow(height, 2));
double volume = (1.0 / 3.0) * M_PI * pow(radius, 2) * height;
double surface_area = M_PI * radius * (radius + slant_height);
cout << "Volume: " << volume << ", Surface Area: " << surface_area << endl;
}
void trapezoid() {
double base1, base2, height, side1, side2;
cout << "Enter the first base of the trapezoid: ";
cin >> base1;
cout << "Enter the second base of the trapezoid: ";
cin >> base2;
cout << "Enter the height of the trapezoid: ";
cin >> height;
cout << "Enter the first side of the trapezoid: ";
cin >> side1;
cout << "Enter the second side of the trapezoid: ";
cin >> side2;
cout << "Area: " << 0.5 * (base1 + base2) * height << ", Circumference: " << base1 + base2 + side1 + side2 << endl;
}
void pentagon() {
double side;
cout << "Enter the side length of the pentagon: ";
cin >> side;
double area = (1.0 / 4.0) * sqrt(5 * (5 + 2 * sqrt(5))) * pow(side, 2);
cout << "Area: " << area << ", Circumference: " << 5 * side << endl;
}
void cuboid() {
double length, width, height;
cout << "Enter the length of the cuboid: ";
cin >> length;
cout << "Enter the width of the cuboid: ";
cin >> width;
cout << "Enter the height of the cuboid: ";
cin >> height;
double volume = length * width * height;
double surface_area = 2 * (length * width + width * height + height * length);
cout << "Volume: " << volume << ", Surface Area: " << surface_area << endl;
}
int main() {
int choice;
do {
cout << "\nChoose a shape to calculate:\n";
cout << "1. Square\n2. Circle\n3. Triangle\n4. Cube\n5. Sphere\n6. Pyramid\n7. Cone\n8. Trapezoid\n9. Pentagon\n10. Cuboid\n0. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: square(); break;
case 2: circle(); break;
case 3: triangle(); break;
case 4: cube(); break;
case 5: sphere(); break;
case 6: pyramid(); break;
case 7: cone(); break;
case 8: trapezoid(); break;
case 9: pentagon(); break;
case 10: cuboid(); break;
case 0: cout << "Exiting the program. Goodbye!\n"; break;
default: cout << "Invalid choice. Please select a valid option.\n";
}
} while (choice != 0);
return 0;
}