예제 #1
0
 /// <summary>
 /// Have custom parameters as well as choose operation
 /// </summary>
 private static void CustomCalculator()
 {
     Console.WriteLine("Press Y to allow negative numbers");
     allowNegativeNumbers = Console.ReadLine() == "Y";
     ProcessAltDelim();
     ProcessUpperBound();
     ProcessDifferentOperation();
     while (!stop)
     {
         Console.WriteLine("Input values to calculate ");
         Console.WriteLine("Press control c to exit");
         Console.WriteLine("For custom delimiters, please follow format //[delim][delim]\\n{numbers}");
         String input = Console.ReadLine();
         //Additional step to prevent anymore calculations
         if (stop == true)
         {
             break;
         }
         FormatOutput        format      = new FormatOutput();
         CalculateOutputLine calculation = format.GetNumbersFromArgument(input, allowNegativeNumbers, newCustomDelimiter, upperBound, operation, true);
         if (calculation != null)
         {
             Console.WriteLine($"Formula was : {calculation.Formula} ");
             Console.WriteLine($"Total was : {calculation.Total}");
         }
     }
 }
예제 #2
0
        static void Main(string[] args)
        {
            FormatOutput format = new FormatOutput();

            Console.CancelKeyPress += new ConsoleCancelEventHandler(CancelKeyPress);
            Console.WriteLine("Welcome User!");
            ProcessDefaultOrNo();
            if (defaultOrCustom == 1)
            {
                DefaultOperation();
            }
            else
            {
                CustomCalculator();
            }
        }
예제 #3
0
 /// <summary>
 /// Use the default calculator
 /// </summary>
 private static void DefaultOperation()
 {
     while (!stop)
     {
         Console.WriteLine("Input values to calculate ");
         Console.WriteLine("Press control c to exit");
         Console.WriteLine("For custom delimiters, please follow format //[delim][delim]\\n{numbers}");
         String input = Console.ReadLine();
         //Additional step to prevent anymore calculations
         if (stop == true)
         {
             break;
         }
         FormatOutput        format      = new FormatOutput();
         CalculateOutputLine calculation = format.GetNumbersFromArgument(input, false, Environment.NewLine, 1000, 1, true);
         if (calculation != null)
         {
             Console.WriteLine($"Formula was : {calculation.Formula} ");
             Console.WriteLine($"Total was : {calculation.Total}");
         }
     }
 }