i'm creating a simple calculator and i've been trying to use switches
to allow the user to select whether they want to add, subtract, multiply or divide their inputted values.
They can also type quit to exit the console. but after case quit
: when i add a method of closing the console such as Environment.Exit(-1);
It throws up an error and using break;
just brings me into my next switch (both of which are in the same while loop as the second one restarts the console).
Any ideas on what i can do?
{
case "add":
answer = (num1 + num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "subtract":
answer = (num1 - num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "multiply":
answer = (num1 * num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "divide":
answer = (num1 / num2);
Console.WriteLine("your answer is {0:0.00}", answer);
break;
case "quit":
}