Skip to content

Commit 20c17cc

Browse files
authored
Updated with newest version
by the way, i made this on repl.it, but decided to publish it on github... maybe you will like it...
1 parent 075c54f commit 20c17cc

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

calculations.cs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
using System;
2+
3+
class calulations{
4+
void factorial(float ofNumber){
5+
for(int i; i = )
6+
}
7+
}

main.cs

+28-23
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,34 @@
22

33
class MainClass {
44
public static void Main (string[] args) {
5-
string[] allowedOperations = {"1","2","3","4","5"};
6-
convertor Con = new convertor();
7-
string cis1, cis2, op;
8-
float vys= 0, c1 = 0, c2= 0;
9-
int o= 0;
10-
Console.WriteLine("Calculator v00nic");
11-
Console.Write("Type first number: ");
12-
cis1 = Console.ReadLine();
13-
Console.Write("Type second number: ");
14-
cis2 = Console.ReadLine();
15-
Con.stringCheck(cis1, cis2, args);
16-
c1 = float.Parse(cis1);
17-
c2 = float.Parse(cis2);
18-
Console.WriteLine("now select Operation: 1-+, 2 - -, 3 - *, 4 - /");
19-
op = Console.ReadLine();
20-
5+
string[] caughtErrors= new string[3]; //something to not get warnings
6+
convertor Con = new convertor(); //convertor class, which contains methods not meeting the software purpose
7+
string cis1, cis2, op; //dem stringz
8+
float vys= 0, c1 = 0, c2= 0; //dem floatz
9+
int o= 0; //Operation
10+
Console.WriteLine("Calculator v00nic"); //Don't mind me
11+
Console.Write("Type first number: "); //i'm just
12+
cis1 = Console.ReadLine(); //reads value from dat Console
13+
Console.Write("Type second number: "); //printing to console
14+
cis2 = Console.ReadLine(); //reads value from dat Console
15+
try{
16+
c1 = float.Parse(cis1);
17+
c2 = float.Parse(cis2);
18+
}
19+
catch(System.FormatException e){
20+
caughtErrors[1] = e.ToString();
21+
Console.WriteLine("Oops! Wrong input format of number input! Preforming restart");
22+
Main(args);
23+
} //try to parse inserted value. if catches "System.FormatException" exception, calls the method to avoid crashing
24+
Console.Write("now select Operation: 1-+, 2 - -, 3 - *, 4 - /, 5 - ^");
25+
op = Console.ReadLine();//reads value fromm dat Console
2126
try{
2227
o = int.Parse(op);
2328
}
2429
catch(System.FormatException e){
30+
caughtErrors[2] = e.ToString();
2531
o=999;
26-
}
32+
}//tries to parse operation, if cathes "System.FormatException" exceptions, makes steps to safely reload the method
2733
switch(o){
2834
case 1: vys = c1+c2; break;
2935
case 2: vys = c1-c2; break;
@@ -33,8 +39,8 @@ public static void Main (string[] args) {
3339
case 999: Console.WriteLine("Sorry, but you inserted invalid value of operation, preforming a quick restart!");
3440
Main(args);
3541
break;
36-
}
37-
Console.WriteLine("I have Counted this: "+ vys.ToString());
42+
}//main operation handler
43+
Console.WriteLine("I have Counted this: "+ vys.ToString()); //print the final vlue
3844

3945
Console.WriteLine("Do You wish to continue?");
4046
Console.Write("(Y/N)");
@@ -47,8 +53,7 @@ public static void Main (string[] args) {
4753
}else{
4854
Console.WriteLine("Unexpected error");
4955
Environment.Exit(1);
50-
}
51-
56+
}//handles if should restart to continue method Y = yes, N = No, anythong else = crash;
5257
}
53-
54-
}
58+
}
59+
//created by github.com/mineikCZ in 2018 (c)

0 commit comments

Comments
 (0)