-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
131 lines (113 loc) · 4.7 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SimpleCalculator // IF you use this source to make something of your own like this, please credit me
{
class Program
{
private const string Title = "SimpleCalculator v1.1"; // i give 0 fucks about what this is
static void Main(string[] args)
{
double val1 = 0, val2 = 0, res = 0;
Console.WriteLine("Simple calculator written in C#. Made by nukiz.");
Console.WriteLine("Initializing...");
Console.Title = Title;
Console.WriteLine("Succesfully Initialized! Press any key to continue.");
Console.ReadLine();
Console.Clear();
int gamer = 69; // place own number if cared enough
while (gamer <= 69) // place own number if cared enough
{
Console.Write("Specify the calculation with freespace between numbers and operation char:\n");
string rawOperation = Console.ReadLine();
string[] vals = rawOperation.Split(' ');
//vals 1 = number 1
//vals 2 = operator
//vals 3 = number 2
if(vals.Length>2)
{
bool firstValIsValid = false;
try
{
val1 = Convert.ToDouble(vals[0]);
firstValIsValid = true;
val2 = Convert.ToDouble(vals[2]);
}
catch (FormatException)
{
if (firstValIsValid)
{
Console.Write("Check second given number!");
}
else
{
Console.Write("Check first given number!");
}
}
// Check if opChar is valid.
if (vals[1].Length == 1)
{
switch (vals[1])
{
case "+":
{
res = val1 + val2;
break;
}
case "-":
{
res = val1 - val2;
break;
}
case "*":
{
res = val1 * val2;
break;
}
case "/":
{
res = val1 / val2;
break;
}
}
Console.WriteLine("Result: " + res.ToString());
}
}
else
{
Console.WriteLine("Check given input!");
}
/*
Console.Write("Specify an number to calculate: "); // you can change the text
double firstNum = Convert.ToDouble(Console.ReadLine());
Console.Write("Specify an operator: "); // you can change the text
string calculationOp = Console.ReadLine(); // variable (string) can be changed if fucks are given
Console.Write("Specify the second number to calculate: "); // you can change text
double secondNum = Convert.ToDouble(Console.ReadLine());
if (calculationOp == "+")
{
Console.WriteLine(firstNum + secondNum);
}
else if (calculationOp == "-")
{
Console.WriteLine(firstNum - secondNum);
}
else if (calculationOp == "x")
{
Console.WriteLine(firstNum * secondNum); // changing this shit doesn't do other than break the calculator.
}
else if (calculationOp == "d")
{
Console.WriteLine(firstNum / secondNum);
}
else
{
Console.WriteLine("Invalid Operator!");
}
Console.ReadLine();*/
}
}
}
}