Good Day,
I have written my 1st C# console application. I have tried looking up the answer to my question, but have not found anything that helps answer it, so here I am turning to you for help. I'm trying to incorporate as many different items in a small
appl. so I can refer to it as I develop other programs, so I included a case structure, a Parse method will probably include an IF then Else, had though about some type of module for this but haven't gotten there yet.
it would not let them continue. I think I could use an if elseif elseif elseif structure to accomplish the task, but isn't there a more concise way to do this? I don't know if a Do While Loop would be in order Isolating the string f = Console.ReadLine(); line would be better or what. Any suggestions would be appreciated. Thank you.
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter the first #:");
int x = int.Parse(Console.ReadLine());
Console.WriteLine("Which Mathematical operation are you going to do?");
string f = Console.ReadLine();
Console.WriteLine("Enter the second #:");
int y = int.Parse(Console.ReadLine());
switch (f){
case "+": // Do Addition Block
int a = x + y;
Console.WriteLine("The answer is: " + a);
break;
case "-": //Do Subtraction Block
int b = x - y;
Console.WriteLine("The answer is: " + b);
break;
case "*": // Do Multiplication Block
int c= x * y;
Console.WriteLine("The answer is: " + c);
break;
case "/": //Do Division Block
int d = x / y;
Console.WriteLine("The answer is: " + d);
break;}
Console.ReadLine();
}
}
}