-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
67 lines (58 loc) · 2.02 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
using System;
using System.Collections.Generic;
using System.Diagnostics.Eventing.Reader;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Simple_calculator
{
internal class Program
{
static void Main(string[] args)
{
Console.Write("Number 1: ");
if (!double.TryParse(Console.ReadLine(), out double number1))
{
Console.WriteLine("\nInvalid number");
return;
}
Console.Write("Number 2: ");
if (!double.TryParse(Console.ReadLine(), out double number2))
{
Console.WriteLine("\nInvalid number");
return;
}
Console.WriteLine("Enter the symbol of operacion (+ - * /");
Console.Write("Your answer: ");
char.TryParse(Console.ReadLine(), out char operation);
switch (operation)
{
case '+':
Console.WriteLine("\nResult of adding = " + (number1 + number2));
break;
case '-':
Console.WriteLine("\nResult of subtraction = " + (number1 - number2));
break;
case '*':
Console.WriteLine("\nResult of multiplication = " + (number1 * number2));
break;
case '/':
if (number2 != 0)
{
Console.WriteLine("\nResult of division = " + (number1 / number2));
break;
}
else
{
Console.WriteLine("\nDivision by 0 is not possible");
break;
}
default:
{
Console.WriteLine("\nInvalid operation");
break;
}
}
}
}
}