All pastes #264867 Raw Edit

Someone

public text v1 · immutable
·published 2006-12-02 20:10 UTC
rendered paste body
public void RunEx02()
        {
            int x; int y; // int result;
            Console.WriteLine("Please enter two numbers to be multiplied...");
        questionFirst:
            Console.Write("First Number: ");
            if (!InputHandle(Console.ReadLine(), out x))
            {
                goto questionFirst;
            }
        questionSecond:
            Console.Write("Second Number: ");
            if (!InputHandle(Console.ReadLine(), out y))
            {
                goto questionSecond;
            }
            Console.Clear();
            Console.WriteLine("The result of {0} and {1} is: {2}\n", x, y, MultR(x, y));
            Console.WriteLine("Have a good day!");
            Console.ReadLine();
        }

static int MultR(int x, int y)
        {
            //int offset = 0;
            if (x > 0)
            {
                if ((0 - x) < 0)
                {
                    y += MultR((x - 1), y);
                    return y;
                }
                else
                {
                    return 0;
                }

            }
            else if (x < 0)
            {
                if ((0 - x) > 0)
                {
                    y = (0 - y);
                    y -= MultR((x + 1), y);
                    return y;
                }
                else
                {
                    return 0;
                }
            }
            else
            {
                return 0;
            }

        }

        static bool InputHandle(string input, out int var)
        {
            if (Int32.TryParse(input, out var))
            {
                return true;
            }
            else
            {
                Console.WriteLine("You need to enter an integer!");
                Console.ReadLine();
                Console.Clear();
                return false;
            }
        }
    }