qq_34418970
想飞的鱼丶
2016-05-04 04:27

怎么写出输入Y/N继续运算

class Operation
{
public int num1;
public int num2;

}
class Program
{
static void Main(string[] args)
{
Console.WriteLine("请输入连个整数");
OperationNum op = new OperationNum();
op.num1 = Convert.ToInt32(Console.ReadLine());
op.num2 = Convert.ToInt32(Console.ReadLine());
// int num1 = Convert.ToInt32(Console.ReadLine());
// int num2 = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("请选择运算符 \n1.加法\n2.减法\n3.乘法\n4.除法 ");

int s = 0;
s = Convert.ToInt32(Console.ReadLine());
switch (s)
{
case 1:
Console.WriteLine("{0}+{1}={2}",op.num1,op.num2,op.Add());

break;
case 2:
Console.WriteLine("差为{0}", op.Sub());
break;
case 3:
Console.WriteLine("积为{0}", op.Mul());
break;
case 4:
Console.WriteLine("商为{0}", op.Mul());
break;

}

}
}
class OperationNum : Operation
{
public int Add()
{
return num1 + num2;
}
public int Sub()
{
return num1 - num2;
}
public int Mul()
{
return num1 * num2;
}
public int Div()
{
return num1 + num2;
}
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

3条回答