/// <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}"); } } }
/// <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}"); } } }