Merge2 2
Merge2 2
2
3 namespace merge2
4 {
5 class Shape
6 {
7 public int radius, height, width, depth;
8 }
9
10 class realstate
11 {
12 public int floor, room, area;
13 }
14
15 class Circle : Shape
16 {
17 public Circle()
18 {
19 Console.WriteLine("Enter the radius of the circle:");
20 radius = int.Parse(Console.ReadLine());
21 }
22
23 public double CalculateArea()
24 {
25 return 3.1416 * radius * radius;
26 }
27
28 public string circle()
29 {
30 return $"Circle with radius {radius}";
31 }
32 }
33
34 class Rectangle : Shape
35 {
36 public Rectangle()
37 {
38 Console.WriteLine("Enter the height and width of the rectangle:");
39 height = int.Parse(Console.ReadLine());
40 width = int.Parse(Console.ReadLine());
41 }
42
43 public int CalculateArea()
44 {
45 return height * width;
46 }
47
48 public string rectangle()
49 {
50 return $"Rectangle with height {height} and width {width}";
51 }
52 }
53
54 class Cube : Shape
55 {
56 public Cube()
57 {
58 Console.WriteLine("Enter the height, width, and depth of the cube:");
59 height = int.Parse(Console.ReadLine());
60 width = int.Parse(Console.ReadLine());
61 depth = int.Parse(Console.ReadLine());
62 }
63
64 public int CalculateArea()
65 {
66 return 2 * ((height * width) + (width * depth) + (height * depth));
67 }
68
69 public string cube()
70 {
71 return $"Cube with height {height}, width {width}, and depth {depth}";
72 }
73 }
74
75 class Apartment : realstate
76 {
77 public Apartment()
78 {
79 Console.WriteLine("Enter floor, room, and area");
80 floor = int.Parse(Console.ReadLine());
81 room = int.Parse(Console.ReadLine());
82 area = int.Parse(Console.ReadLine());
83 }
84 public int GetArea()
85 {
86 return area;
87 }
88 public string apartment()
89 {
90 return $"Apartment in {floor}th floor with {room} rooms and an area of
{area} sqft";
91 }
92 }
93
94 class Hostel : realstate
95 {
96 public Hostel()
97 {
98 Console.WriteLine("Enter room and area");
99 room = int.Parse(Console.ReadLine());
100 area = int.Parse(Console.ReadLine());
101 }
102 public int GetArea()
103 {
104 return area;
105 }
106
107 public string hostel()
108 {
109 return $"Hostel with {room} rooms and an area of {area} sqft";
110 }
111 }
112
113 class Office : realstate
114 {
115 public Office()
116 {
117 Console.WriteLine("Enter floor, room, and area");
118 floor = int.Parse(Console.ReadLine());
119 room = int.Parse(Console.ReadLine());
120 area = int.Parse(Console.ReadLine());
121 }
122
123 public int GetArea()
124 {
125 return area;
126 }
127
128 public string office()
129 {
130 return $"Office in {floor}th floor with {room} rooms and an area of {area}
sqft";
131 }
132 }
133
134 class Program
135 {
136 static void Main(string[] args)
137 {
138 Shape[] shapes = new Shape[100];
139 realstate[] Real = new realstate[100];
140 int circleCount = 0;
141 int rectangleCount = 0;
142 int cubeCount = 0;
143 double totalCircleArea = 0;
144 int totalRectangleArea = 0;
145 int totalCubeArea = 0;
146 int shapeCount = 0;
147 int hostelcount = 0, apartmentcount = 0, officecount = 0, realcount = 0;
148 int harea = 0, aarea = 0, oarea = 0;
149 string[] shapestype= new string[100];
150 string[] shapesname= new string[100];
151 while (true)
152 {
153 Console.WriteLine("1. Geometric");
154 Console.WriteLine("2. Realstate");
155 Console.WriteLine("3. Exit");
156 int x = int.Parse(Console.ReadLine());
157 if (x == 1)
158 {
159 while (true)
160 {
161 Console.WriteLine("1. Add circle");
162 Console.WriteLine("2. Add rectangle");
163 Console.WriteLine("3. Add cube");
164 Console.WriteLine("4. Item list");
165 Console.WriteLine("5. Statistics");
166 Console.WriteLine("6. Back");
167 Console.WriteLine("7. Exit");
168
169 int n = int.Parse(Console.ReadLine());
170
171 if (n == 1)
172 {
173 Circle circle = new Circle();
174 totalCircleArea += circle.CalculateArea();
175 shapestype[shapeCount] =circle.circle();
176 circleCount++;
177 shapeCount++;
178 }
179 else if (n == 2)
180 {
181 Rectangle rectangle = new Rectangle();
182 shapestype[shapeCount] =rectangle.rectangle();
183 totalRectangleArea += rectangle.CalculateArea();
184 rectangleCount++;
185 shapeCount++;
186 }
187 else if (n == 3)
188 {
189 Cube cube = new Cube();
190 shapestype[shapeCount] =cube.cube();
191 totalCubeArea += cube.CalculateArea();
192 cubeCount++;
193 shapeCount++;
194 }
195 else if (n == 4)
196 {
197 Console.WriteLine("Item List:");
198 for (int i = 0; i < shapeCount; i++)
199 {
200 Console.WriteLine($"{i + 1} is {shapestype[i]}");
201 }
202 }
203 else if (n == 5)
204 {
205 Console.WriteLine($"Number of circles: {circleCount}");
206 Console.WriteLine($"Number of rectangles: {rectangleCount}");
207 Console.WriteLine($"Number of cubes: {cubeCount}");
208 Console.WriteLine($"Total area of circles:
{totalCircleArea:F3}");
209 Double p = (totalCircleArea * 100) / (totalCircleArea +
totalRectangleArea + totalCubeArea);
210 Console.WriteLine($"Percentage of circle: {p}");
211 Console.WriteLine($"Total area of rectangles:
{totalRectangleArea}");
212 p = (totalRectangleArea * 100) / (totalCircleArea +
totalRectangleArea + totalCubeArea);
213 Console.WriteLine($"Percentage of rectangle: {p}");
214 Console.WriteLine($"Total area of cubes: {totalCubeArea}");
215 p = (totalCubeArea * 100) / (totalCircleArea +
totalRectangleArea + totalCubeArea);
216 Console.WriteLine($"Percentage of cube: {p}");
217 Console.WriteLine($"Total area: {totalCircleArea +
totalRectangleArea + totalCubeArea}");
218 }
219 else if (n == 6)
220 {
221 break;
222 }
223 else if (n == 7)
224 {
225 Console.WriteLine("--------THE END----------");
226 Environment.Exit(0);
227 }
228 }
229 }
230 else if (x == 2)
231 {
232 while (true)
233 {
234 Console.WriteLine("1. Apartment");
235 Console.WriteLine("2. Hostel");
236 Console.WriteLine("3. Office");
237 Console.WriteLine("4. Itemlist");
238 Console.WriteLine("5. Statistics");
239 Console.WriteLine("6. Back");
240 Console.WriteLine("7. Exit");
241 int y = int.Parse(Console.ReadLine());
242
243 if (y == 1)
244 {
245 Apartment apartment = new Apartment();
246 shapesname[realcount] = apartment.apartment();
247 aarea += apartment.GetArea();
248 apartmentcount++;
249 realcount++;
250 }
251 else if (y == 2)
252 {
253 Hostel hostel = new Hostel();
254 shapesname[realcount]=hostel.hostel();
255 harea += hostel.GetArea();
256 hostelcount++;
257 realcount++;
258 }
259 else if (y == 3)
260 {
261 Office office = new Office();
262 shapesname[realcount]=office.office();
263 oarea += office.GetArea();
264 officecount++;
265 realcount++;
266 }
267 else if (y == 4)
268 {
269 Console.WriteLine("Item List:");
270 for (int i = 0; i < realcount; i++)
271 {
272 Console.WriteLine($"{i + 1} is {shapesname[i]}");
273 }
274 }
275 else if (y == 5)
276 {
277 Console.WriteLine($"Total area of Apartment: {aarea}");
278 Double p = (aarea * 100.00) / (aarea + harea + oarea);
279 Console.WriteLine($"Percentage of Apartment: {p}");
280 Console.WriteLine($"Total area of Hostel: {harea}");
281 p = (harea * 100.00) / (aarea + harea + oarea);
282 Console.WriteLine($"Percentage of Hostel: {p}");
283 Console.WriteLine($"Total area of Office: {oarea}");
284 p = (oarea * 100.00) / (aarea + harea + oarea);
285 Console.WriteLine($"Percentage of office: {p}");
286 Console.WriteLine($"Total area: {aarea + harea + oarea}");
287 }
288 else if (y == 6)
289 {
290 break;
291 }
292 else if (y == 7)
293 {
294 Console.WriteLine("--------THE END----------");
295 Environment.Exit(0);
296 }
297 }
298 }
299 else if (x == 3)
300 {
301 Console.WriteLine("--------THE END----------");
302 Environment.Exit(0);
303 }
304 }
305 }
306 }
307 }
308