0% found this document useful (0 votes)
14 views8 pages

Merge

Uploaded by

ahmadpsh305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views8 pages

Merge

Uploaded by

ahmadpsh305
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

C:\Users\HP\source\repos\Merge\Program.

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

You might also like