Пример #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
        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();
        }
Пример #3
0
        static void Main(string[] args)
        {
            int         num01;
            int         num02;
            Calculation obj = new Calculation();

            //New Logic.
            Console.WriteLine("Enter the First value to be divided");
            num01 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the Secound value to divided by");
            num02 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("The Result is: " + obj.Divide(num01, num02));
            Console.ReadLine();

            // Logic For Addition.
            Console.WriteLine("Enter the First value to be Added");
            num01 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the Secound value to Added ");
            num02 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("The Result is: " + obj.Add(num01, num02));
            Console.ReadLine();

            // Losic For substraction.
            Console.WriteLine("Enter the First value to be Subtacted");
            num01 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the Secound value to Subtracted");
            num02 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("The Result is: " + obj.Subtract(num01, num02));
            Console.ReadLine();

            // Logic For multiplication.
            Console.WriteLine("Enter the First value to be Multiplied");
            num01 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("enter the Secound value to Multiplied ");
            num02 = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("The Result is: " + obj.Multiply(num01, num02));
            Console.ReadLine();



            //OLd Logic.
            //Console.WriteLine("Enter the First value to be divided");
            //num01 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("enter the Secound value to divided by");
            //num02 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("The Result is: " + (num01 / num02));
            //Console.ReadLine();

            //// Logic For Addition.
            //Console.WriteLine("Enter the First value to be Added");
            //num01 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("enter the Secound value to Added ");
            //num02 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("The Result is: " + (num01 + num02));
            //Console.ReadLine();

            //// Losic For substraction.
            //Console.WriteLine("Enter the First value to be Subtacted");
            //num01 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("enter the Secound value to Subtracted");
            //num02 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("The Result is: " + (num01 - num02));
            ////Console.ReadLine();

            //// Logic For multiplication.
            //Console.WriteLine("Enter the First value to be Multiplied");
            //num01 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("enter the Secound value to Multiplied ");
            //num02 = Convert.ToInt32(Console.ReadLine());
            //Console.WriteLine("The Result is: " + (num01 * num02));
            //Console.ReadLine();
        }