标题:超简单的计算器。 不准笑哈
只看楼主
qq1004974443
Rank: 1
来 自:重庆
等 级:新手上路
帖 子:9
专家分:3
注 册:2010-10-13
结帖率:0
 问题点数:0 回复次数:13 
超简单的计算器。 不准笑哈
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
c1_wangyf
Rank: 11Rank: 11Rank: 11Rank: 11
等 级:小飞侠
威 望:7
帖 子:665
专家分:2832
注 册:2010-5-24
得分:0 
哈哈,不错!!鼓励一下
2010-10-13 08:55
staythink
Rank: 2
等 级:论坛游民
帖 子:42
专家分:50
注 册:2010-7-26
得分:0 
8错。

be a progammer,instead of a coder~
2010-10-13 13:02
筱晓绾
Rank: 10Rank: 10Rank: 10
来 自:湖南
等 级:贵宾
威 望:12
帖 子:512
专家分:1736
注 册:2010-9-1
得分:0 
...
2010-10-13 13:11
hxxiaoxiao
Rank: 2
等 级:论坛游民
威 望:1
帖 子:29
专家分:81
注 册:2010-10-13
得分:0 
         
2010-10-13 15:40
jackvc
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2010-10-13
得分:0 
2010-10-13 17:22
zybnrq
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2010-9-25
得分:0 
很好!

2010-10-14 11:16
wayneshen
Rank: 2
等 级:论坛游民
帖 子:17
专家分:10
注 册:2010-10-14
得分:0 
很好啊!比我强多了 我只能看懂但是让我自己编一个就不行了
2010-10-14 12:20
zhouh198981
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2010-10-18
得分:0 
2010-10-18 21:52
zhaoxili
Rank: 6Rank: 6
等 级:侠之大者
威 望:1
帖 子:327
专家分:479
注 册:2009-1-3
得分:0 
继续努力
2010-10-19 00:51



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-322739-1-1.html




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

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