コード例 #1
0
        public static void ResultValue(double result)
        {
            Program.DisplayMessage($"\nYour final result is {result}.", ConsoleColor.Green);
            Console.ReadKey();

            UserChoices.CalculatorContinuation();
        }
コード例 #2
0
        public static void Sub(double firstNumber, char operater)
        {
            try
            {
                double subSecond = AskUserForNumbers.AskUserForNumberTwo(firstNumber, operater);

                double result = firstNumber - subSecond;

                Result.ResultValue(result);
                UserChoices.SubtractionContinuation(result);
            }
            catch (Exception)
            {
                Program.DisplayMessage("\nPlease try again", ConsoleColor.Red);
            }
        }
コード例 #3
0
        public static void Add(double firstNumber, char operater)
        {
            try
            {
                double addFirst  = firstNumber;
                double addSecond = AskUserForNumbers.AskUserForNumberTwo(firstNumber, operater);

                double result = addFirst + addSecond;

                Result.ResultValue(result);
                UserChoices.AdditionContinuation(result);
            }
            catch (Exception)
            {
                Program.DisplayMessage("\nSomething went wrong. Please try again", ConsoleColor.Red);
            }
        }
コード例 #4
0
        public static void SubLoop(double result)
        {
            try
            {
                char choice = '-';

                double subThird = AskUserForNumbers.AskUserForNumberTwo(result, choice);

                result -= subThird;

                Result.ResultValue(result);
                UserChoices.SubtractionContinuation(result);
            }
            catch (Exception)
            {
                Program.DisplayMessage("\nSomething went wrong. Please try again!", ConsoleColor.Red);
            }
        }
コード例 #5
0
        public static void AddLoop(double result)
        {
            try
            {
                char operater = '+';

                double addThird = AskUserForNumbers.AskUserForNumberTwo(result, operater);

                result += addThird;

                Result.ResultValue(result);
                UserChoices.AdditionContinuation(result);
            }
            catch (Exception)
            {
                Program.DisplayMessage("\nSomething went wrong. Please try again", ConsoleColor.Red);
            }
        }