loner_li 机试题 编写一个简单的计算器实现加减乘除:输入两个数字和一个运算符号,输出结果(注意容错性)

namespace 机试题简单计算器
{
    class Program
    {
        //编写一个简单的计算器实现加减乘除:输入两个数字和一个运算符号,输出结果(注意容错性)
        static void Main(string[] args)
        {
            Console.WriteLine("请输入1个数字");
            double db = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("请输入\"+\",\"-\",\"*\",\"/\"任意1种运算符");
            string ss = Console.ReadLine();
            Console.WriteLine("请再次输入1个数字:");
            double db1 = Convert.ToDouble(Console.ReadLine());
            switch (ss)
            {
                case "+":
                    double db2 = db + db1;
                    Console.WriteLine("进行加法运算的结果为" + db2);
                    break;
                case "-":
                    double db3 = db - db1;
                    Console.WriteLine("进行减法运算的结果" + db3);
                    break;
                case "*":
                    double db4 = db * db1;
                    Console.WriteLine("进行乘法运算的结果为" + db4);
                    break;
                case "/":
                    double db5 = db /db1;
                    Console.WriteLine("进行除法运算的结果" + db5);
                    break;
                   
                default:
                    Console.WriteLine("您输入的运算符有误!!");
                    break;

            }

            Console.ReadKey();

        }
    }
}

你可能感兴趣的:(C#,C#,机试题)