-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
120 lines (87 loc) · 3.53 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
using System;
namespace Calculator
{
class Program
{
static void Main(string[] args)
{
Menu();
}
static void Menu()
{
Console.Clear();
Console.WriteLine("Welcome! Select below which mathematical operation you want to perform:");
Console.WriteLine("");
Console.WriteLine("1 => Sum");
Console.WriteLine("2 => Subtraction");
Console.WriteLine("3 => Division");
Console.WriteLine("4 => Multiplication");
Console.WriteLine("5 => Exit");
Console.WriteLine("");
Console.Write("Enter your choice: ");
short menuResult = short.Parse(Console.ReadLine());
switch (menuResult)
{
case 1: Sum(); break;
case 2: Subtraction(); break;
case 3: Division(); break;
case 4: Multiplication(); break;
case 5: System.Environment.Exit(0); break;
default: Menu(); break;
}
Console.ReadKey();
}
static void Sum()
{
Console.Clear();
Console.WriteLine("[Sum] Enter the first value:");
float sumFirstValue = float.Parse(Console.ReadLine());
Console.WriteLine("[Sum] Enter the second value:");
float sumSecondValue = float.Parse(Console.ReadLine());
Console.WriteLine("=============================");
float sumResult = sumFirstValue + sumSecondValue;
Console.WriteLine($"Result of the sum is: {sumResult}");
Console.ReadKey();
Menu();
}
static void Subtraction()
{
Console.Clear();
Console.WriteLine("[Subtraction] Enter the first value:");
float subFirstValue = float.Parse(Console.ReadLine());
Console.WriteLine("[Subtraction] Enter the second value:");
float subSecondValue = float.Parse(Console.ReadLine());
Console.WriteLine("=====================================");
float subResult = subFirstValue - subSecondValue;
Console.WriteLine($"Result of the subtraction is: {subResult}");
Console.ReadKey();
Menu();
}
static void Division()
{
Console.Clear();
Console.WriteLine("[Division] Enter the first value:");
float divFirstValue = float.Parse(Console.ReadLine());
Console.WriteLine("[Division] Enter the second value:");
float divSecondValue = float.Parse(Console.ReadLine());
Console.WriteLine("==================================");
float divResult = divFirstValue / divSecondValue;
Console.WriteLine($"Result of the division is: {divResult}");
Console.ReadKey();
Menu();
}
static void Multiplication()
{
Console.Clear();
Console.WriteLine("[Multiplication] Enter a first value:");
float multiFirstValue = float.Parse(Console.ReadLine());
Console.WriteLine("[Multiplication] Enter a second value:");
float multiSecondValue = float.Parse(Console.ReadLine());
Console.WriteLine("======================================");
float multiResult = multiFirstValue * multiSecondValue;
Console.WriteLine($"Result of the multiplication is: {multiResult}");
Console.ReadKey();
Menu();
}
}
}