-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathArea.cpp
More file actions
57 lines (53 loc) · 1.81 KB
/
Copy pathArea.cpp
File metadata and controls
57 lines (53 loc) · 1.81 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
#include <iostream>
#include "Square.h"
#include "Triangle.h"
#include "CircleHeader.h"
#include "AreaHeader.h"
using namespace std;
int main() {
int choice;
while (true) {
cout << "1. Calculate the area of a square" << endl;
cout << "2. Calculate the area of a triangle" << endl;
cout << "3. Calculate the area of a circle" << endl;
cout << "4. Quit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1: {
float side;
cout << "Enter the side length of the square: ";
cin >> side;
shapes::Square square(side);
float area = Area::calculateSquareArea(square);
cout << "The area of the square is: " << area << endl;
break;
}
case 2: {
float 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);
float area = Area::calculateTriangleArea(triangle);
cout << "The area of the triangle is: " << area << endl;
break;
}
case 3: {
float radius;
cout << "Enter the radius of the circle: ";
cin >> radius;
shapes::Circle circle(radius);
float area = Area::calculateCircleArea(circle);
cout << "The area of the circle is: " << area << endl;
break;
}
case 4:
return 0;
default:
cout << "Invalid choice. Please try again." << endl;
}
}
return 0;
}