Beispiel #1
0
        static void Main(string[] args)
        {
            Calculator1 x = new Calculator1();

            int i = 1;

            do
            {
                int    number1   = Convert.ToInt32(Console.ReadLine());
                string calculate = Console.ReadLine();


                if (calculate == "^")
                {
                    Console.WriteLine(x.Sq(number1));
                }

                else
                {
                    int number2 = Convert.ToInt32(Console.ReadLine());

                    if (calculate == "+")
                    {
                        Console.WriteLine(x.Add(number1, number2));
                    }
                    else if (calculate == "*")
                    {
                        Console.WriteLine(x.Mult(number1, number2));
                    }
                    else if (calculate == "-")
                    {
                        Console.WriteLine(x.Sub(number1, number2));
                    }
                    else if (calculate == "/")
                    {
                        Console.WriteLine(x.Div(number1, number2));
                    }
                }

                i++;
            }while (i < 50);

            Console.ReadKey();
        }
 public void WhenIPressAdd()
 {
     result = calculator.Add();
 }