-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (37 loc) · 1.57 KB
/
Program.cs
File metadata and controls
40 lines (37 loc) · 1.57 KB
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
namespace BasicCalculator
{
class Program
{
static void Main()
{
// Welcoming message
Console.WriteLine("Welcome to the Basic Calculator program!");
Console.WriteLine("You can use this to perform simple calculations.");
Calculator calculator = new Calculator();
while (true)
{
// Get operation that user wishes to use
OperationType operation = calculator.GetOperation();
// Execute calculator code to show history or do testing and skip rest of the loop
if (operation == OperationType.History || operation == OperationType.Test)
{
calculator.Execute();
continue;
}
// Exit program if they have chosen to exit
else if (operation == OperationType.Exit)
{
Console.WriteLine("Thank you for using the Basic Calculator! Goodbye.\n");
break;
}
// Get input numbers from user
calculator.first = calculator.GetNumber("Enter your first number: ");
// Skip second number if the selected operation is square root
if (operation != OperationType.SquareRoot)
calculator.second = calculator.GetNumber("Enter your second number: ");
// Execute operation and print out result
Console.WriteLine(calculator.Execute());
}
}
}
}