-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
106 lines (92 loc) · 3.06 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
namespace CalculatorConsole
{
using System;
using System.Threading;
using static Calculator;
using static BiCalculator;
using static PiCalculator;
internal class Program
{
public static bool isError = false;
public static int output;
public const string one = "1", two = "2", three = "3";
private static void Main()
{
var mainThread = Thread.CurrentThread;
mainThread.IsBackground = false;
mainThread.Priority = ThreadPriority.Highest;
Calculate();
}
public static void Calculate()
{
Console.ForegroundColor = ConsoleColor.White;
Console.WriteLine("Choose calculation type: ");
Console.WriteLine(" ");
Console.WriteLine(one + ": Decimal math, its accurate, but you can't use BigInteger size numbers.");
Console.WriteLine(" ");
Console.WriteLine(two + ": BigInteger math, unfortunately, only one operator at a time is supported.");
Console.WriteLine(" ");
Console.WriteLine(three + ": Calculates pi to given number of digits.");
Console.WriteLine("Way better and faster algo with a decimal point too. Perfectly accurate, 100K digits in 20 seconds");
Console.WriteLine(" ");
Console.WriteLine("Press enter to exit the console.");
Console.WriteLine(" ");
SwitchMathType();
}
public static void SwitchMathType()
{
var inputString = Console.ReadLine();
var digits = int.TryParse(inputString, out output);
if (digits || inputString == "")
{
switch (inputString)
{
case one:
SmallMath();
break;
case two:
BigMath();
break;
case three:
CalculatePi();
break;
case "":
Exit();
break;
}
}
else
{
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine(" ");
Calculate();
}
}
public static void Exit()
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(" ");
Console.WriteLine("Are you sure you want to exit? y/n");
Console.WriteLine(" ");
var yes = "y";
var no = "n";
var answer = Console.ReadLine();
if (answer == yes)
{
Environment.Exit(0);
}
else if (answer == no)
{
Console.WriteLine(" ");
Console.WriteLine(" ");
Console.WriteLine(" ");
Calculate();
}
else
{
Exit();
}
}
}
}