예제 #1
0
        static void Main(string[] args)
        {
            double      a         = EnterNumber1();
            char        operation = EnterOperator();
            double      b         = EnterNumber2();
            Calculation c         = new Calculation();


            switch (operation)
            {
            case '+':
                PrintResult(c.Sum(a, b).ToString());
                break;

            case '-':
                PrintResult(c.Diff(a, b).ToString());
                break;

            case '*':
                PrintResult(c.Multiply(a, b).ToString());
                break;

            case '/':
                PrintResult(c.Division(a, b).ToString());
                break;

            case '%':
                PrintResult(c.RemainderOfDivision(a, b).ToString());
                break;
            }
            Console.ReadLine();
        }
예제 #2
0
        private void ExecuteOperation()
        {
            switch (Operation)
            {
            case "+":
                LabelResult.Text = Calculation.Summin(FirstNum, SecondNum).ToString();
                break;

            case "-":
                LabelResult.Text = Calculation.Subtraction(FirstNum, SecondNum).ToString();
                break;

            case "*":
                LabelResult.Text = Calculation.Multiplication(FirstNum, SecondNum).ToString();
                break;

            case "/":
                LabelResult.Text = Calculation.Division(FirstNum, SecondNum);
                break;

            case "^":
                LabelResult.Text = Calculation.Exponentiation(FirstNum, SecondNum).ToString();
                break;

            case "root":
                LabelResult.Text = Calculation.RootExtraction(FirstNum, SecondNum);
                break;

            default:
                break;
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            int  a         = EnterNumber1();
            char operation = EnterOperator();
            int  b         = EnterNumber2();

            Calculation calc = new Calculation();

            switch (operation)
            {
            case '+':
                PrintResult(calc.Sum(a, b).ToString());
                break;

            case '-':
                PrintResult(calc.Diff(a, b).ToString());
                break;

            case '*':
                PrintResult(calc.Multiply(a, b).ToString());
                break;

            case '/':
                try
                {
                    PrintResult(calc.Division(a, b).ToString());
                }
                catch (DivideByZeroException)
                {
                    Console.WriteLine("Divide by zero");
                }
                break;
            }
            Console.ReadKey();
        }