| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1568 人关注过本帖, 1 人收藏
标题:超简单的计算器。 不准笑哈
取消只看楼主 加入收藏
qq1004974443
Rank: 1
来 自:重庆
等 级:新手上路
帖 子:9
专家分:3
注 册:2010-10-13
结帖率:0
收藏(1)
 问题点数:0 回复次数:0 
超简单的计算器。 不准笑哈
using System;
    class jsq
    {
        public double jiafa(double a, double b)
        {
            double reasult;
            reasult = a + b;
            return reasult;
        }
        public double jianfa(double a, double b)
        {
            double reasult;
            reasult = a - b;
            return reasult;
        }
        public double chengfa(double a, double b)
        {
            double reasult;
            reasult = a * b;
            return reasult;
        }
        public double chufa(double a, double b)
        {
            double reasult;
            reasult = a / b;
            return reasult;
        }
        static void Main(string[] args)
        {
            double a;
            double b;
            double c;
            string  d;
            Console.WriteLine("请输入第一个数字");
            a = Convert.ToDouble(Console.ReadLine());
            Console.WriteLine("请输入第二个数字");
            b = Convert.ToDouble(Console.ReadLine());
            jsq js = new jsq();
            Console.WriteLine("请输入你要进行的计算方式:");
            Console.Write("+\t-\t*\t/");
            Console.WriteLine();
            d = Console.ReadLine();
            switch (d)
            {
                case "+":
                    {
                        c = js.jiafa(a, b);
                        Console.WriteLine("加法结果为:{0}", c);
                    }
                    break;
                case "-":
                    {
                        c = js.jianfa(a, b);
                        Console.WriteLine("减法结果为:{0}", c);
                    }
                    break;
                case "*":
                    {
                        c = js.chengfa(a, b);
                        Console.WriteLine("乘法结果为:{0}", c);
                    }
                    break;
                case "/":
                    {
                        if (b != 0)
                        {
                            c = js.chufa(a, b);
                            Console.WriteLine("加法结果为:{0}", c);
                        }
                        else
                        {
                            Console.WriteLine("除法结果为:Error ! 除数不能为0");
                        }
                    }
                    break;
                default :
                      Console.WriteLine("本计算器目前只支持'+','-','*','/'");
                      break;
            }

         
            Console.ReadLine();
        }
    }
搜索更多相关主题的帖子: 计算器 
2010-10-13 00:18
快速回复:超简单的计算器。 不准笑哈
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017203 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved