Exemple #1
0
        public void userSelection()
        {
            Calculator calc = new Calculator(); //Creating an object to access the calculator methods


            Console.Write("Please enter the first number: ");
            double testnum = Convert.ToDouble(Console.ReadLine());

            Console.Write("Please enter the operator: ");
            string operators = Console.ReadLine();

            Console.Write("Please enter the second number: ");
            double testnum2 = Convert.ToDouble(Console.ReadLine());

            if (operators == "+")
            {
                Console.WriteLine("Total: " + calc.Adding(testnum, testnum2));
            }
            else if (operators == "-")
            {
                Console.WriteLine("Total: " + calc.Subtraction(testnum, testnum2));
            }
            else if (operators == "*")
            {
                Console.WriteLine("Total: " + calc.Multiply(testnum, testnum2));
            }
            else if (operators == "/")
            {
                Console.WriteLine("Total: " + calc.Divide(testnum, testnum2));
            }
            else if (operators == "%")
            {
                Console.WriteLine("Total: " + calc.Remainder(testnum, testnum2));
            }
            else
            {
                Console.WriteLine("Invalid control, please try again!");
                userSelection();
            }
        }