-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.cpp
More file actions
63 lines (53 loc) · 1.74 KB
/
Copy pathMain.cpp
File metadata and controls
63 lines (53 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <iostream>
#include <string>
#include "Square.h"
#include "Triangle.h"
#include "Circle.h"
#include "Area.h"
using namespace std;
int main() {
int choice;
bool quit = false;
while (!quit) {
cout << "Select an option:" << endl;
cout << "1. Calculate area of a square" << endl;
cout << "2. Calculate area of a triangle" << endl;
cout << "3. Calculate area of a circle" << endl;
cout << "4. Quit" << endl;
cout << "Enter your choice: ";
cin>>choice;
if (choice == 1) {
double side;
cout << "Enter the side length of the square: ";
cin >> side;
shapes::Square square(side);
double area = Area::calculateSquareArea(square);
cout << "The area of the square is: " << area << endl;
}
else if (choice == 2) {
double base, height;
cout << "Enter the base of the triangle: ";
cin >> base;
cout << "Enter the height of the triangle: ";
cin >> height;
shapes::Triangle triangle(base, height);
double area = Area::calculateTriangleArea(triangle);
cout << "The area of the triangle is: " << area << endl;
}
else if (choice == 3) {
double radius;
cout << "Enter the radius of the circle: ";
cin >> radius;
shapes::Circle circle(radius);
double area = Area::calculateCircleArea(circle);
cout << "The area of the circle is: " << area << endl;
}
else if (choice == 4) {
quit = true;
}
else {
cout << "Invalid choice. Please try again." << endl;
}
}
return 0;
}