问答详情
源自:6-8 最终项目

帮我看看为什么输入不了运算符号那步

                    做了个计算器程序,但是输入运算符号那步直接跳过去了

                    Console.WriteLine("请输入第一个数");
                    float oneNumberInCalculator;
                    oneNumberInCalculator = Console.Read();
                    Console.WriteLine("请输入运算符号");
                    Console.WriteLine("1为加,2为减,3为乘,4为除");
                    int arithmeticSymbol;
                    arithmeticSymbol = Console.Read();
                    if (arithmeticSymbol == 1)
                    {
                        Console.WriteLine("请输入第二个数");
                        float twoNumberInCalculater;
                        twoNumberInCalculater = Console.Read();
                        Console.WriteLine("运算结果为");
                        Console.WriteLine(oneNumberInCalculator + twoNumberInCalculater);
                    }
                    if (arithmeticSymbol == 2)
                    {
                        Console.WriteLine("请输入第二个数");
                        float twoNumberInCalculater;
                        twoNumberInCalculater = Console.Read();
                        Console.WriteLine("运算结果为");
                        Console.WriteLine(oneNumberInCalculator - twoNumberInCalculater);
                    }
                    if (arithmeticSymbol == 3)
                    {
                        Console.WriteLine("请输入第二个数");
                        float twoNumberInCalculater;
                        twoNumberInCalculater = Console.Read();
                        Console.WriteLine("运算结果为");
                        Console.WriteLine(oneNumberInCalculator * twoNumberInCalculater);
                    }
                    if (arithmeticSymbol == 4)
                    {
                        Console.WriteLine("请输入第二个数");
                        float twoNumberInCalculater;
                        twoNumberInCalculater = Console.Read();
                        Console.WriteLine("运算结果为");
                        Console.WriteLine(oneNumberInCalculator / twoNumberInCalculater);
                    }

提问者:宇宙黑暗森林博弈论 2018-08-20 17:51

个回答

  • Lu__ffy
    2018-08-25 12:15:40

    Read