using System;
namespace TestU
{
class Calc
{
public static void main(String[] args)
{
Console.Write("请输入数字A: ");
string A = Console.ReadLine();
Console.Write("请选择运算符号(+、-、*、/): ");
string B= Console.ReadLine();
Console.Write("请输入数字B: ");
string B = Console.ReadLine();
string C = Console.ReadLine();
string D = "";
if(B == "+")
D = Convert.ToString(Convert.ToDouble(A) + Convert.ToDouble(C));
if(B == "-")
D = Convert.ToString(Convert.ToDouble(A) - Convert.ToDouble(C));
if(B == "*")
D = Convert.ToString(Convert.ToDouble(A) * Convert.ToDouble(C));
if(B == "/")
D = Convert.ToString(Convert.ToDouble(A) / Convert.ToDouble(C));
Console.WriteLine("结果是:"+D);
}
}
}
上面的程序是OOP,C#写的计算器,,大家看看有什么问题。。。
|