-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
246 lines (197 loc) · 9.83 KB
/
Program.cs
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
using System;
using System.Threading;//for using thread.sleep method
namespace Lab02
{
class Program //this is demo repositpory select the end is near
{
public void menu()
{
string choice = "-1";
//asdfadsf
// changes no changes i dont like sarah ka change therefore i will have my own change. Tableegh
const float pi = 3.14f;
while (choice != "0")
{
Thread.Sleep(5000);//pausing control for 1sec
Console.Clear();
Console.WriteLine("\n\tPress + to Addition numbers:");
Console.WriteLine("\tPress - to Subtract numbers:");
Console.WriteLine("\tPress / to Divide numbers:");
Console.WriteLine("\tPress * to Multiply numbers:");
Console.WriteLine("\tPress % to Modules numbers:");
Console.WriteLine("\tPress s for Squreroot of number:");
Console.WriteLine("\tPress r for Rounding a number:");
Console.WriteLine("\tPress c for checking numbers:");//comparison
Console.WriteLine("\tEnter max for finding maxmimum number:");
Console.WriteLine("\tEnter min for finding minimum number:");
Console.WriteLine("\tEnter A for finding area of Circle:");
Console.WriteLine("\tPress 0 to Exit: \n\n");
choice = Console.ReadLine();
switch (choice)
{
case "+":
{
Console.Clear();
int sum = 0;
Console.WriteLine("Enter the amount of Number you want to add: ");
int i = Convert.ToInt32(Console.ReadLine());
for (int j = 0; j < i; j++)
{
Console.WriteLine("Enter Number: ");
int num1 = Convert.ToInt32(Console.ReadLine());
sum += num1;
}
Console.WriteLine("Answer of Addition is: " + sum);
break;
}
case "-":
{
Console.Clear();
int subtarcat = 0;
Console.WriteLine("Enter the amount of Number you want to subtract: ");
int i = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
subtarcat = Convert.ToInt32(Console.ReadLine());
for (int j = 1; j < i; j++)
{
Console.WriteLine("Enter Number: ");
int num1 = Convert.ToInt32(Console.ReadLine());
subtarcat -= num1;
}
Console.WriteLine("Answer of Subtarction is: " + subtarcat);
break;
}
case "*":
{
Console.Clear();
Console.WriteLine("Enter the amount of Number you want to multiply: ");
int i = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
float multiply = Convert.ToInt32(Console.ReadLine());
for (int j = 1; j < i; j++)
{
Console.WriteLine("Enter Number: ");
float num1 = float.Parse(Console.ReadLine());
multiply *= num1;
}
Console.WriteLine("Answer of Multiplication is: " + multiply);
break;
}
case "/":
{
Console.Clear();
Console.WriteLine("Enter the amount of Number you want to divide : ");
int i = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
float divide = Convert.ToInt32(Console.ReadLine());
for (int j = 1; j < i; j++)
{
Console.WriteLine("Enter Number: ");
int num1 = Convert.ToInt32(Console.ReadLine());
divide /= num1;
}
Console.WriteLine("Answer of Division is: " + divide);
break;
}
case "s":
{
Console.Clear();
Double sqrt = 0d;
Console.WriteLine("Enter Number: ");
sqrt = Double.Parse(Console.ReadLine());
sqrt = Math.Sqrt(sqrt);
Console.WriteLine("Answer of Squre Root is: " + sqrt);
break;
}
case "%":
{
Console.Clear();
float mod = 0;
Console.WriteLine("Enter Number: ");
mod = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
int num1 = Convert.ToInt32(Console.ReadLine());
mod %= num1;
Console.WriteLine("Answer of Modules is: " + mod);
break;
}
case "c":
{
Console.Clear();
Console.WriteLine("Enter Number: ");
int num1 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
int num2 = Convert.ToInt32(Console.ReadLine());
if (num1 > num2)
{
Console.WriteLine("Number " + num1 + " Is greater than Number " + num2);
}
else if (num1 < num2)
{
Console.WriteLine("Number " + num1 + " Is lesser than Number " + num2);
}
else
{
Console.WriteLine("Number " + num1 + " Is equal to Number " + num2);
}
break;
}
case "r":
{
Console.Clear();
Console.WriteLine("Enter Number: ");
double num = double.Parse(Console.ReadLine());
num = Math.Round(num);
Console.WriteLine("The rounded Number is: " + num);
break;
}
case "max":
{
Console.Clear();
Console.WriteLine("Enter Number: ");
int max = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
int num2 = Convert.ToInt32(Console.ReadLine());
max = Math.Max(max, num2);
Console.WriteLine("The Maximum Number is: " + max);
break;
}
case "min":
{
Console.Clear();
Console.WriteLine("Enter Number: ");
int min = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Enter Number: ");
int num2 = Convert.ToInt32(Console.ReadLine());
min = Math.Min(min, num2);
Console.WriteLine("The Minimum Number is: " + min);
break;
}
case "A":
{
Console.Clear();
Console.WriteLine("Enter Radius of Circle: ");
float radius = float.Parse(Console.ReadLine());
float area = pi * (radius * radius);
Console.WriteLine("The area of circle is: " + area);
break;
}
case "0":
break;
default:
{
Console.Clear();
Console.WriteLine("Incorrect Input Enter Again");
break;
}
}
}
}
static void Main(string[] args)
{
Console.WriteLine("\n\n\t\tCaculator: ");
Program obj = new Program();
obj.menu();
}
}
}