第二次作业

namespace boke
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b;
            Random rd = new Random();
            a = rd.Next(0, 11);
            b = rd.Next(0, 11);
            Console.WriteLine("第一个数:{0}",a);
            Console .WriteLine ("第二个数:{0}",b);
            Console.WriteLine("请输入运算符号:'+','-','*','/'");
            string c = Console.ReadLine();
            if (c == "+")
            {
                int d;
                d = a + b;
                Console.WriteLine ("结果是:");
                Console.ReadLine();
                Console.WriteLine("正确答案是:{0}", d); 
            }
            else if (c == "-")
            {
                int d;
                d = a - b;
                Console.WriteLine("结果是:");
                Console.ReadLine();
                Console.WriteLine("正确答案是:{0}", d); 
            }
            else if (c == "*")
            {
                int d;
                d = a * b;
                Console.WriteLine("结果是:");
                Console.ReadLine();
                Console.WriteLine("正确答案是:{0}", d); 
            }
            else if (c == "/")
            {
                int d;
                d = a / b;
                Console.WriteLine("结果是:");
                Console.ReadLine();
                Console.WriteLine("正确答案是:{0}", d); 
            }
            else
            {
                Console.WriteLine("您输入的运算符无效");
            }
            Console .ReadLine ();
        }
    }
}

1、看清题目的要求,编写简单计算器的代码。

2、选择相应的程序进行编写。

3、要想产生随机数,首先用Random进行定义。

4、然后对四个运算符号进行描述。

5、最后把正确结果写出,进行运行测试。

因为能力有限,编写的代码不太符合要求,望老师多多谅解。

原文地址:https://www.cnblogs.com/githubgxp/p/4856378.html