课后作业二

码云项目地址:https://gitee.com/libolinaaa/homework_ii
 
 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("输入一个数字:");
            int a = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("输入运算符(+—*/)");
            // c=Console.ReadLine();
            char str = Convert.ToChar(Console.ReadLine());

            Console.WriteLine("第二个数:");
            int b = Int32.Parse(Console.ReadLine());

            //int c = a + b;
            //Console.WriteLine("和为:{0}",c);

            switch (str)
            {
                case '+':
                    Console.WriteLine("和为:{0}", a + b);

                    break;
                case '-':
                    Console.WriteLine("差为:{0}", a - b);
                    break;
                case '*':
                    Console.WriteLine("积为:{0}", a * b);
                    break;
                case '/':
                    Console.WriteLine("商为:{0}", a / b);
                    break;
                case '%':
                    Console.WriteLine("余数为:{0}", a % b);
                    break;
                default:
                    Console.WriteLine("请输入正确的运算符!!");
                    break;

            }
            Console.ReadKey();
        }
    }
}  
posted @ 2019-01-11 18:48  lbl李  阅读(99)  评论(0编辑  收藏  举报