Console.WriteLine(“Enter the Second Number:”); number2=Convert.ToInt32(Console.ReadLine());
Console.WriteLine(“Main Menu”); Console.WriteLine(“1.Addition”); Console.WriteLine(“2.Subtraction”); Console.WriteLine(“3.Multiplication”); Console.WriteLine(“4.Division”);
Console.WriteLine(“Enter the Operation you want to perform:”); option=Convert.ToChar(Console.ReadLine()); switch(option) { case 1 : result=number1 + number2; break; case 2 : result=number1 - number2; break; case 3 : result=number1 * number2; break; case 4 : result=number1 / number2; break; default: Console.WriteLine(“Invalid Option”); return; }
Console.WriteLine(“The result is {0}” , result);
}
}
class TestCalc {
static void Main(string[] args) {
CalcNumber obj = new CalcNumber(); obj.Number(); } }
从键盘输入8和2两个整数时,