Beispiel #1
0
        public void Calculate(string sing)
        {
            double ret = nums.Pop();

            while (nums.getTop() != 0)
            {
                if (sing == "+")
                {
                    ret += nums.Pop();
                }
                else if (sing == "-")
                {
                    ret -= nums.Pop();
                }
                else if (sing == "*")
                {
                    ret *= nums.Pop();
                }
                else if (sing == "/")
                {
                    ret /= nums.Pop();
                }
                else
                {
                    ret %= nums.Pop();
                }
            }

            nums.Push(ret);
            Console.WriteLine(ret);
        }