-
Notifications
You must be signed in to change notification settings - Fork 0
/
Class1.cs
392 lines (338 loc) · 11 KB
/
Class1.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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
using System;
using System.Transactions;
namespace Operations
{
// Creation of a class called "SumOp"
public class SumOp
{
// Class Method
public double Sum(double Num1, double Num2)
{
double Res_Sum; // Declaration of a variable
Res_Sum = Num1 + Num2;
return Res_Sum; // Value return
}
}
// Creation of a class called "SustOp"
public class SustOp
{
// Class Method
public double Sust(double Num1, double Num2)
{
double Res_Sust; // Declaration of a variable
Res_Sust = Num1 - Num2;
return Res_Sust; // Value return
}
}
// Creation of a class called "MultOp"
public class MultOp
{
// Class Method
public double Mult(double Num1, double Num2)
{
double Res_Mult; // Declaration of a variable
Res_Mult = Num1 * Num2;
return Res_Mult; // Value return
}
}
// Creation of a class called "DivOp"
public class DivOp
{
// Class Method
public double Div(double Num1, double Num2)
{
double Res_Div; // Declaration of a variable
Res_Div = Num1 / Num2;
return Res_Div; // Value return
}
}
// Creation of a class called "SquR"
public class SquR
{
double x = 1.0; // Variable declaration
// Class Method
public double Square(double Num1)
{
double Res_SquR; // Variable declaration
// for loop
for (int k = 1; k < 10; k++)
{
x = (x + Num1 / x) / 2;
}
Res_SquR = x; // Variable "Res_SquR" is assigned "x" value
return Res_SquR; // Value return
}
}
// Creation of a class called "Percentage"
public class Percentage
{
// Class Method
public double Percent(double Num1)
{
double Res_Perc; // Variable declaration
Res_Perc = (Num1) / (100);
return Res_Perc; // Value return
}
}
// Creation of a class called "xCubed"
public class xCubed
{
// Class Method
public double xCub(double Num1)
{
double Res_Cubed; // Variable declaration
Res_Cubed = Num1 * Num1 * Num1;
return Res_Cubed; // Value return
}
}
// Creation of a class called "xSqurd"
public class xSqurd
{
// Class Method
public double xSqr(double Num1)
{
double Res_Squr; // Variable declaration
Res_Squr = Num1 * Num1;
return Res_Squr; // Value return
}
}
// Creation of a class called "xRNeg1"
public class xRNeg1
{
// Class method
public double xNeg1(double Num1)
{
double Res_xNegt; // Variable declaration
Res_xNegt = 1 / Num1;
return Res_xNegt; // Value return
}
}
// Creation of a class called "Raised10"
public class Raised10
{
double Res_RTen = 1; // Variable declaration
// Class method
public double TenRx(double Num1)
{
// for loop
for (int k = 1; k <= Num1; k++)
{
Res_RTen *= 10;
}
return Res_RTen; // Value return
}
}
// Creation of a class called "Factorial"
public class Factorial
{
double Res_Fac = 1; // Variable declaration
// Class Method
public double FactOp(double Num1)
{
// for loop
for (double k = 1; k <= Num1; k++)
{
Res_Fac *= k;
}
return Res_Fac; // Value return
}
}
// Creation of a class called "Exp"
public class Exp
{
// Class method
public double NumExp(double Num1, double Num2)
{
double Res_PowNum = Num1; // Variable declaration
// for loop
for (int k = 1; k < Num2; k++)
{
Res_PowNum *= Num1;
}
return Res_PowNum; // Value return
}
}
// Creation of a class called "Logarithm"
public class Logarithm
{
/*
--- FORMULA ---
Log_10(a) ≈ 0.87x * (A + 1)
that means...
x = [(a - 1) / (a + 1)]
and
A = x^2 * [(1/3) + { (1/5)x^2} ]
--- Variables ---
a = The number that you want to calculate it logarithm
*/
// Class method
public double Log(double Num1)
{
double x, A, Res_Log; // Variable declaration
x = (Num1 - 1) / (Num1 + 1);
A = (x * x) * ((1 / 3) + (1 / 5) * (x * x));
Res_Log = 0.87 * x * (A + 1);
return Res_Log; // Value return
}
}
// Creation of a class called "NatLog"
public class NatLog
{
/*
--- FORMULA ---
Log_10(a) ≈ [0.87x * (A + 1)] * 2.3025
that means...
x = [(a - 1) / (a + 1)]
and
A = x^2 * [(1/3) + { (1/5)x^2} ]
--- Variables ---
a = The number that you want to calculate it logarithm
*/
// Class method
public double NaturalLog(double Num1)
{
double x, A, Res_NatLog; // Variable declaration
x = (Num1 - 1) / (Num1 + 1);
A = (x * x) * ((1 / 3) + (1 / 5) * (x * x));
Res_NatLog = (0.87 * x * (A + 1)) * 2.3025;
return Res_NatLog; // Value return
}
}
// Creation of a class called "sin"
public class sin
{
// Class Method
public double Sin(double Num1)
{ // Dividendo // Divisor
double Res_Sin, Dividend, Divider, sig; // Variable declaration
int i, j; // Variable declaration
Res_Sin = 0;
// for loop
for (i = 0; i <= 20; i++)
{
Dividend = 1;
// for loop
for (j = 0; j < (2 * i + 1); j++) // ---------------------- //
{ // ------ DIVIDEND ------ //
Dividend *= Num1; // ---------------------- //
}
Divider = 1;
// for loop
for (j = 1; j <= (2 * i + 1); j++) // --------------------- //
{ // ------ DIVIDER ------ //
Divider *= j; // --------------------- //
}
// if
if (i % 2 == 0)
{
sig = 1;
}
// else
else
{
sig = -1;
}
Res_Sin += (Dividend / Divider) * sig;
}
return Res_Sin; // Value return
}
}
// Creation of a class called "cos"
public class cos
{
// Class Method
public double Cos(double Num1)
{
// Dividendo // Divisor
double Res_Cos, Dividend, Divider, sig; // Variable declaration
int i, j; // Variable declaration
Res_Cos = 0;
// for loop
for (i = 0; i <= 20; i++)
{
Dividend = 1;
// for loop
for (j = 0; j < (2 * i); j++) // ---------------------- //
{ // ------ DIVIDEND ------ //
Dividend *= Num1; // ---------------------- //
}
Divider = 1;
// for loop
for (j = 2; j <= (2 * i); j++) // --------------------- //
{ // ------ DIVIDER ------ //
Divider *= j; // --------------------- //
}
// if
if (i % 2 == 0)
{
sig = -1;
}
// else
else
{
sig = 1;
}
Res_Cos = Res_Cos - (Dividend / Divider) * sig;
}
return Res_Cos; // Value return
}
}
// Creation of a class called "sinh"
public class sinh
{
// Class Method
public double Sinh(double Num1)
{
double Res_Sinh, Dividend, Divider; // Variable declaration
int i, j; // Variable declaration
Res_Sinh = 0;
// for loop
for (i = 0; i <= 20; i++)
{
Dividend = 1;
// for loop
for (j = 0; j < (2 * i + 1); j++) // ---------------------- //
{ // ------ DIVIDEND ------ //
Dividend *= Num1; // ---------------------- //
}
Divider = 1;
// for loop
for (j = 1; j <= (2 * i + 1); j++) // --------------------- //
{ // ------ DIVIDER ------ //
Divider *= j; // --------------------- //
}
Res_Sinh += (Dividend / Divider);
}
return Res_Sinh; // Value return
}
}
// Creation of a class called "cosh"
public class cosh
{
// Class Method
public double Cosh(double Num1)
{
double Res_Cosh, Dividend, Divider; // Variable declaration
int i, j; // Variable declaration
Res_Cosh = 0;
// for loop
for (i = 0; i <= 20; i++)
{
Dividend = 1;
// for loop
for (j = 0; j < (2 * i); j++) // ---------------------- //
{ // ------ DIVIDEND ------ //
Dividend *= Num1; // ---------------------- //
}
Divider = 1;
// for loop
for (j = 1; j <= (2 * i); j++) // --------------------- //
{ // ------ DIVIDER ------ //
Divider *= j; // --------------------- //
}
Res_Cosh += (Dividend / Divider);
}
return Res_Cosh; // Value return
}
}
}