class Program
{
static void Main(string[] args)
{
int num1;
int num2;
string operand;
float answer;
Console.Write("Please enter the first integer: ");
num1 = Convert.ToInt32(Console.ReadLine());
Console.Write("Please enter an operand (+, -, /, *): ");
operand = Console.ReadLine();
Console.Write("Please enter the second integer: ");
num2 = Convert.ToInt32(Console.ReadLine());
switch (operand)
{
case "-":
answer = num1 - num2;
break;
case "+":
answer = num1 + num2;
break;
case "/":
answer = num1 / num2;
break;
case "*":
answer = num1 * num2;
break;
default:
answer = 0;
break;
}
Console.WriteLine(num1.ToString() + " " + operand + " " + num2.ToString() + " = " + answer.ToString());
Console.ReadLine();
}
}
Join the conversation! Your thoughts help the community grow.
Sign in to leave a comment
It is the same account you read, post and publish with — and you will come straight back to this page.

Rocko MontgomeryPosted Apr 12, 2018, 1:07 AM
Looking to do same thing but with 2 options at start. 1. Calculate 2. Exit . Then if calculate there is add subtract or divide . How would I achieve this change ? Thanks from a complete beginner
Christ stopherPosted Sep 10, 2013, 8:40 AM
Thank for easily tut,