public string GetTaskResult(TaskExtractor extractor) { string taskResult; if (extractor.GetNumber(out int number, new string[] { "Input number", "Input number must be greater than zero:" }) && number > 0) { taskResult = $"Fibonachi sequence = {OutputService.ConvertIEnumerableToString(FindFibonachiSequence(number))}"; }
public string GetTaskResult(TaskExtractor extractor) { string taskResult; if (extractor.GetNumber(out var arrSize, "Input array size:")) { var arr = extractor.GetRandomDoubleEnumerable(arrSize).ToArray(); taskResult = string.Concat ( $"{OutputService.ConvertIEnumerableToString(arr)} \nThe sum of the negative elements =", $"{FindSumNegativeElements(arr)}\n", $"The product of the elements of the vector located between the maximum and minimum elements. =", $"{FindMultiplyOfElementsBetweenMaxAndMin(arr)}" ); } else { taskResult = "Input error: Invalid array size!"; } return(taskResult); }
public string GetTaskResult(TaskExtractor extractor) { string taskResult; if (extractor.GetNumber(out var arrSize, "Input array size:")) { var arr = extractor.GetRandomDoubleEnumerable(arrSize).ToArray(); OutputService.ConvertIEnumerableToString(arr); taskResult = string.Concat( $"{OutputService.ConvertIEnumerableToString(arr)} \nThe sum of the negative elements =", $"Max number in the vector = { arr.Max() }\n" + $"Sum elements before last positive = { Math.Round(SumElementsBeforeLastPositive(arr), 2) }"); } else { taskResult = "Input error: Invalid array size!"; } return(taskResult); }