public void Decimal_EmptySource_ThrowsInvalidOperationException() { decimal[] source = new decimal[0]; Assert.Throws <InvalidOperationException>(() => source.Average()); Assert.Throws <InvalidOperationException>(() => source.Average(i => i)); }
public decimal[] Train(decimal[][] xs, decimal[] ys) { if (xs.Length != ys.Length) { throw new ArgumentException("m is not correct"); } var resultThetas = new decimal[xs[0].Length + 1]; bool isFirstRun = true; bool isMinus = false; bool isFinish = false; while (!isFinish) { decimal[] avgDifference = new decimal[xs[0].Length + 1]; for (int i = 0; i < xs.Length; i++) { var hypothesis = this.activationFunction.Calculate(xs[i], resultThetas); avgDifference[0] = hypothesis - ys[i]; for (int j = 0; j < xs[i].Length; j++) { avgDifference[j + 1] = (hypothesis - ys[i]) * xs[i][j]; } } if (isFirstRun) { if (avgDifference[0] == 0) { break; } if (avgDifference[0] < 0) { isMinus = true; } isFirstRun = false; } else if (isMinus && avgDifference.Average() >= -LIMIT || !isMinus && avgDifference.Average() <= LIMIT) { break; } resultThetas[0] = resultThetas[0] - alpha * avgDifference[0] / xs.Length; for (int i = 0; i < xs[0].Length; i++) { resultThetas[i + 1] = resultThetas[i + 1] - alpha * avgDifference[i + 1] / xs.Length; } } return(resultThetas); }
public async Task AverageAwaitWithCancellationAsync_Selector_Decimal_Many() { var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAwaitWithCancellationAsync((x, ct) => new ValueTask <decimal>(x), CancellationToken.None)); }
public async Task AverageAwaitAsync_Selector_Decimal_Many() { var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAwaitAsync(x => new ValueTask <decimal>(x))); }
public async Task AverageAsync_Decimal_Many() { var xs = new decimal[] { 2, 3, 5, 7, 11, 13, 17, 19 }; var ys = xs.ToAsyncEnumerable(); Assert.Equal(xs.Average(), await ys.AverageAsync()); }
private static void CalculateAverage() { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Welcome to \"Calculate Average Wizard\" :]"); Console.ForegroundColor = ConsoleColor.White; Console.Write("Please set the length of the sequence: "); int length = int.Parse(Console.ReadLine()); if (length == 0) { Console.Clear(); Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Number should be NON - NEGATIVE. Please input another!"); CalculateAverage(); } else { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine("Now, enter a sequence of integer numbers:"); decimal[] myArray = new decimal[length]; for (int index = 0; index < length; index++) { Console.Write("number[{0}]= ", index + 1); myArray[index] = int.Parse(Console.ReadLine()); } Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("The Average of a given sequence is: {0}", myArray.Average()); } }
static void Main(string[] args) { bool choice = true; while (choice) { decimal[] invoices = new decimal[5]; decimal total = 0; Console.Write("Enter the total of invoice 1: "); invoices[0] = Convert.ToDecimal(Console.ReadLine()); Console.Write("Enter the total of invoice 2: "); invoices[1] = Convert.ToDecimal(Console.ReadLine()); Console.Write("Enter the total of invoice 3: "); invoices[2] = Convert.ToDecimal(Console.ReadLine()); Console.Write("Enter the total of invoice 4: "); invoices[3] = Convert.ToDecimal(Console.ReadLine()); Console.Write("Enter the total of invoice 5: "); invoices[4] = Convert.ToDecimal(Console.ReadLine()); Console.WriteLine(); Console.WriteLine("using a for loop..."); Console.WriteLine(); for (int i = 0; i < invoices.Length; i++) { total += invoices[i]; Console.WriteLine(invoices[i].ToString("c")); } Console.WriteLine("Total: " + total.ToString("c")); Console.WriteLine(); Console.WriteLine("using a fooreach loop..."); Console.WriteLine(); total = 0; //foreach foreach (decimal inv in invoices) { total += inv; Console.WriteLine(inv.ToString("c")); } Console.WriteLine($"Total: {total.ToString("c")}"); Console.WriteLine($"Average: {invoices.Average()}"); Console.Write("Restart (Y/N): "); choice = Console.ReadLine().ToLower() == "y"; } Console.WriteLine("Goodbye"); Console.ReadLine(); }
public void ParamsTeste() { var decimais = new decimal[] { 2.1m, 1.6m, -8 }; Console.WriteLine(Media(decimais));//chamar o método média Console.WriteLine(Media(1.9m, 2.19m, -8m)); Console.WriteLine(decimais.Average()); }
public void ParamsTeste() { var decimais = new decimal[] { 0.5m, 7, 0.9m, -1.4m }; Console.WriteLine(Media(decimais)); Console.WriteLine(Media(1.5m, 8, 0.5m, 25)); Console.WriteLine(decimais.Average()); }
public void ParamsTeste() { var decimais = new decimal[] { 2.1m, 1.6m, -8m }; Console.WriteLine(Media(decimais)); Console.WriteLine(Media(2.1m, 1.6m, -8m)); //'params' no método media Console.WriteLine(decimais.Average()); }
public void ParamsTeste() { var decimais = new decimal[] { 2.1m, 1.6m, -8 }; Console.WriteLine(Media(decimais)); Console.WriteLine(Media(1.9m, 2.1m, 22, 0.3m)); Console.WriteLine(decimais.Average()); }
public void ParamsTest() { var decimais = new decimal[] { 0.5M, 7, 0.9M, -1.4M }; Console.WriteLine(Media(decimais)); Console.WriteLine(Media(1.5M, 8, 0.5M, 25)); Console.WriteLine(decimais.Average()); }
static void Main(string[] args) { const int ARRAY_SIZE = 10; // This is to declare the size of array decimal[] arrayNumbers = new decimal[ARRAY_SIZE]; // This is to declare the decimal array and to also // initialize it with the size of the array int numberValue = 0; // This will store the value of arrays inputed by the user. //Introducing a do-while loop to ensure that immediately the user finishes to input 10 values, it will // jump out of the loop to evalute the Total,mean, minimum and maximum values respectively. // the data sanitization statements such as "if statement" is to ensure that the user do not input any // value that is not in the range of 0 and 100. The "try-catch" statement is to ensure that the application // will not crash when ever a user inputs any non numeric value or any other error that might arise while // processing the input values do { try { Console.WriteLine("Please enter 10 values between 0 and 100"); arrayNumbers[numberValue] = decimal.Parse(Console.ReadLine()); if (arrayNumbers[numberValue] < 0 || arrayNumbers[numberValue] > 100) { Console.WriteLine($"The number you entered is out of range.You entered {arrayNumbers[numberValue]}.\n Please try again"); } else { numberValue++; } } catch (Exception excp) { Console.WriteLine($"The value you entered is non numeric. \n {excp.Message} Please Try again."); } } while (numberValue < ARRAY_SIZE); // The foreach loop is to output all the values provided by the user foreach (int value in arrayNumbers) { Console.WriteLine($"Values Entered: {value,11:N2}"); } // this is to display the Total, Mean, Minimum and Maximum values provided by the user Console.WriteLine($"Total: {arrayNumbers.Sum(),20:N2}"); Console.WriteLine($"Mean: {arrayNumbers.Average(),19:N2}"); Console.WriteLine($"Minumum:{arrayNumbers.Min(),19:N2}"); Console.WriteLine($"Maximum:{arrayNumbers.Max(),19:N2}"); }
public void ParamsTeste() { Console.WriteLine(Media(new decimal [] { 10, 10, 10, 10 })); decimal[] decimais = new decimal[] { 4, 5, 6, 7 }; Console.WriteLine(Media(1.9m, 2.34m, 3.54m)); Console.WriteLine(decimais.Average()); }
public static List <decimal> MovingAverage(this List <decimal> data, int period) { decimal[] interval = new decimal[period]; List <decimal> MAs = new List <decimal>(); for (int i = 0; i < data.Count(); i++) { interval[i % period] = data[i]; if (i > period - 1) { MAs.Add(interval.Average()); } } return(MAs); }
public static void Pb02() { decimal[] numere = new decimal[] { 40, 30, 50, 20, 10 }; Console.WriteLine($"\n\t Numbers are: "); foreach (var val in numere) { Console.Write($"\t {val} "); } Console.WriteLine($"\n\n\t Sum: {numere.Sum()}"); Console.WriteLine($"\n\t Product: {numere.Product()}"); Console.WriteLine($"\n\t Average: {numere.Average()}"); Console.WriteLine($"\n\t Minimum: {numere.Min()}"); Console.WriteLine($"\n\t Maximum: {numere.Max()}"); }
static void Main(string[] args) { int agents = int.Parse(Console.ReadLine()); int[] agentsOffers = new int[agents]; decimal[] values = new decimal[agents]; for (int i = 0; i < agents; i++) { agentsOffers[i] = int.Parse(Console.ReadLine()); values[i] = 0; for (int offer = 0; offer < agentsOffers[i]; offer++) { int area = int.Parse(Console.ReadLine()); decimal price = decimal.Parse(Console.ReadLine()); values[i] += area * price; } } Console.WriteLine(Math.Round(values.Average(), 3)); }
public decimal Fit(IList <BitfinexCandle> series, int lookbackLength) { var x = series.Skip(series.Count - lookbackLength - 1).ToList(); decimal[] delta = new decimal[x.Count - 1]; for (int i = 0; i < x.Count - 1; i++) { delta[i] = x[i + 1].Open - x[i].Open; } decimal[] upval = new decimal[delta.Length]; decimal[] downval = new decimal[delta.Length]; for (int i = 0; i < delta.Length; i++) { if (delta[i] > 0) { upval[i] = delta[i]; downval[i] = 0; } else { upval[i] = 0; downval[i] = -delta[i]; } } var up = upval.Average(); var down = downval.Average(); if (up + down == 0) { return(1); } else { return(up / (up + down)); } }
static void Averege() { Console.WriteLine("\nEnter integer elements of the sequence in one lane separated by ','"); string input = Console.ReadLine(); if (input.Length == 0) { Console.WriteLine("\nThe sequence should NOT be empty!!\n"); while (true) { Console.Write("Try again? (Y/N): "); string answer = Console.ReadLine(); if (answer == "Y" || answer == "N") { if (answer == "Y") { Averege(); } else if (answer == "N") { Main(); } } } } string[] inputToArray = input.Replace(" ", string.Empty).Split(','); decimal[] sequence = new decimal[inputToArray.Length]; for (int i = 0; i < inputToArray.Length; i++) { sequence[i] = int.Parse(inputToArray[i]); } decimal averege = sequence.Average(); Console.WriteLine("\nAverege: {0}", averege); Continue(); }
static void Main() { var testArr1 = new int[5]; for (int i = 0; i < testArr1.Length; i++) { testArr1[i] = 10; } var sumTest = testArr1.Sum(); Console.WriteLine(sumTest); var testArr2 = new double[5]; for (int i = 0; i < testArr2.Length; i++) { testArr2[i] = 10; } var productTest = testArr2.Product(); Console.WriteLine(productTest); var testArr3 = new decimal[5]; for (int i = 0; i < testArr3.Length; i++) { testArr3[i] = i; } testArr3[2] = -3.14M; testArr3[1] = 1000M; var minTest = testArr3.Min(); var maxTest = testArr3.Max(); var avrTest = testArr3.Average(); Console.WriteLine(minTest); Console.WriteLine(maxTest); Console.WriteLine(avrTest); }
static void Main(string[] args) { int names = int.Parse(Console.ReadLine()); var students = new Dictionary <string, List <decimal> >(); for (int i = 0; i < names; i++) { string[] student = Console.ReadLine().Split(); string name = student[0]; decimal grade = decimal.Parse(student[1]); if (!students.ContainsKey(name)) { students.Add(name, new List <decimal>()); } students[name].Add(grade); } foreach (var(name, grade) in students) { var allGrades = string.Join(" ", grade.Select(x => x.ToString("f2"))); var averageGrades = grade.Average(); Console.WriteLine($"{name} -> {allGrades} (avg: {averageGrades:f2})"); } //foreach (var (name, grade) in students) //{ // Console.Write($"{name} -> "); // foreach (var gradeValue in grade) // { // Console.Write($"{gradeValue:f2} "); // } // Console.WriteLine($"(avg: {grade.Average():f2})"); //} }
public static void Executa() { var turmaA = new string[] { "Teste 1", "Teste 2" }; foreach (var aluno in turmaA) { WriteLine(aluno); } var turmaB = new string[5]; turmaB[0] = "Teste 3"; turmaB[1] = "Teste 4"; turmaB[2] = "Teste 5"; turmaB[3] = "Teste 6"; turmaB[4] = "Teste 7"; foreach (var aluno in turmaB) { WriteLine(aluno); } var notas = new decimal[] { 10M, 8M, 9M }; WriteLine(notas.Average().ToString("F2", CultureInfo.CreateSpecificCulture("en-US"))); }
/// <summary> /// Calculates the average true range over a set of candles. /// </summary> /// <param name="input">Set of candles.</param> /// <returns>AverageTrueRange value.</returns> /// <exception cref="InvalidOperationException">For an empty set.</exception> public static decimal AverageTrueRange(this IEnumerable <BacktestingCandle> input) { var candles = (input ?? throw new ArgumentNullException(nameof(input))).ToArray(); if (candles.Length < 2) { throw new InvalidOperationException($"Cannot calculate the AverageTrueRange of a set containing {candles.Length} candles."); } var trueRanges = new decimal[candles.Length - 1]; // Calculate maximum of three edge features over the series (edgeCandle -> chunk[0] -> chunk[1] ... -> chunk[n]) for (int i = 1; i < candles.Length; i++) { decimal highLow = Math.Abs(candles[i].High - candles[i].Low); decimal highPreviousClose = Math.Abs(candles[i].High - candles[i - 1].Close); decimal lowPreviousClose = Math.Abs(candles[i].Low - candles[i - 1].Close); trueRanges[i - 1] = new[] { highLow, highPreviousClose, lowPreviousClose }.Max(); } return(trueRanges.Average()); }
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); decimal[] income = new decimal[n]; decimal[] expences = new decimal[n]; decimal[] profit = new decimal[n]; for (int i = 0; i < n; i++) { int adultsCount = int.Parse(Console.ReadLine()); decimal adultsPrice = decimal.Parse(Console.ReadLine()); int youthsCount = int.Parse(Console.ReadLine()); decimal youthsPrice = decimal.Parse(Console.ReadLine()); decimal fuelPrice = decimal.Parse(Console.ReadLine()); decimal fuelConsum = decimal.Parse(Console.ReadLine()); int flightDur = int.Parse(Console.ReadLine()); income[i] = (adultsCount * adultsPrice) + (youthsCount * youthsPrice); expences[i] = flightDur * fuelConsum * fuelPrice; profit[i] = income[i] - expences[i]; if (profit[i] < 0) { Console.WriteLine("We've got to sell more tickets! We've lost {0:F3}$.", profit[i]); } else { Console.WriteLine("You are ahead with {0:f3}$.", profit[i]); } } decimal overall = profit.Sum(); decimal average = profit.Average(); Console.WriteLine("Overall profit -> {0:F3}$.", overall); Console.WriteLine("Average profit -> {0:F3}$.", average); }
static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); Dictionary <string, List <decimal> > studentInfo = new Dictionary <string, List <decimal> >(); for (int i = 0; i < n; i++) { var input = Console.ReadLine().Split(' ', StringSplitOptions.RemoveEmptyEntries).ToArray(); string name = input[0]; decimal grade = decimal.Parse(input[1]); if (studentInfo.ContainsKey(name)) { studentInfo[name].Add(grade); } else { studentInfo.Add(name, new List <decimal>()); studentInfo[name].Add(grade); } } foreach (var(name, grade) in studentInfo) { Console.Write($"{name} -> "); foreach (var grades in grade) { Console.Write($"{grades:f2} "); } Console.WriteLine($"(avg: {grade.Average():f2})"); } }
public static decimal?BuildAverageBuy(List <Watcher> watchers) { // Return null if there are no watchers if (watchers.Count == 0) { return(null); } // Collect values var values = new decimal[watchers.Count]; for (var i = 0; i < watchers.Count; i++) { var buy = watchers[i].Buy; if (!buy.HasValue) { throw new ArgumentException("We expect watchers with buy sells"); } values[i] = buy.Value; } // Return return(values.Average()); }
public static int Main() { try { var boolArray = new bool[] { true, false, true, false, false, true }; SafeArrayNative.XorBoolArray(boolArray, out var xorResult); Assert.Equal(XorArray(boolArray), xorResult); var decimalArray = new decimal[] { 1.5M, 30.2M, 6432M, 12.5832M }; SafeArrayNative.MeanDecimalArray(decimalArray, out var meanDecimalValue); Assert.Equal(decimalArray.Average(), meanDecimalValue); SafeArrayNative.SumCurrencyArray(decimalArray, out var sumCurrencyValue); Assert.Equal(decimalArray.Sum(), sumCurrencyValue); var strings = new [] { "ABCDE", "12345", "Microsoft" }; var reversedStrings = strings.Select(str => Reverse(str)).ToArray(); var ansiTest = strings.ToArray(); SafeArrayNative.ReverseStringsAnsi(ansiTest); AssertExtensions.CollectionEqual(reversedStrings, ansiTest); var unicodeTest = strings.ToArray(); SafeArrayNative.ReverseStringsUnicode(unicodeTest); AssertExtensions.CollectionEqual(reversedStrings, unicodeTest); var bstrTest = strings.ToArray(); SafeArrayNative.ReverseStringsBSTR(bstrTest); AssertExtensions.CollectionEqual(reversedStrings, bstrTest); var blittableRecords = new SafeArrayNative.BlittableRecord[] { new SafeArrayNative.BlittableRecord { a = 1 }, new SafeArrayNative.BlittableRecord { a = 5 }, new SafeArrayNative.BlittableRecord { a = 7 }, new SafeArrayNative.BlittableRecord { a = 3 }, new SafeArrayNative.BlittableRecord { a = 9 }, new SafeArrayNative.BlittableRecord { a = 15 }, }; AssertExtensions.CollectionEqual(blittableRecords, SafeArrayNative.CreateSafeArrayOfRecords(blittableRecords)); var nonBlittableRecords = boolArray.Select(b => new SafeArrayNative.NonBlittableRecord { b = b }).ToArray(); AssertExtensions.CollectionEqual(nonBlittableRecords, SafeArrayNative.CreateSafeArrayOfRecords(nonBlittableRecords)); var objects = new object[] { new object(), new object(), new object() }; SafeArrayNative.VerifyIUnknownArray(objects); SafeArrayNative.VerifyIDispatchArray(objects); var variantInts = new object[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 }; SafeArrayNative.MeanVariantIntArray(variantInts, out var variantMean); Assert.Equal(variantInts.OfType <int>().Average(), variantMean); var dates = new DateTime[] { new DateTime(2008, 5, 1), new DateTime(2010, 1, 1) }; SafeArrayNative.DistanceBetweenDates(dates, out var numDays); Assert.Equal((dates[1] - dates[0]).TotalDays, numDays); SafeArrayNative.XorBoolArrayInStruct( new SafeArrayNative.StructWithSafeArray { values = boolArray }, out var structXor); Assert.Equal(XorArray(boolArray), structXor); } catch (Exception e) { Console.WriteLine(e); return(101); } return(100); }
public static void Main() { List <int> testInts = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; byte[] testByte = new byte[] { 1, 2, 3, 4, 5 }; decimal[] testDecimal = new decimal[] { 1.0m, 2.5m, 4.5m, 7.5m, 11m }; string[] testString = new string[] { "abc", "def", "Kedar" }; int[] testNull = new int[] { }; int[] testZero = new int[] { -2, 2 }; //testing Sum Console.WriteLine("Testing Sum-----------------------------------------------"); Console.WriteLine(); int sumInts = testInts.Sum(); Console.WriteLine(sumInts); byte sumBytes = testByte.Sum(); Console.WriteLine(sumBytes); decimal sumDecimal = testDecimal.Sum(); Console.WriteLine(sumDecimal); string sumStrings = testString.Sum(); Console.WriteLine(sumStrings); // Console.WriteLine(testNull.Sum()); Console.WriteLine(testZero.Sum()); //testing Product Console.WriteLine(); Console.WriteLine("Testing Product-----------------------------------------------"); Console.WriteLine(); int prodInts = testInts.Product(); Console.WriteLine(prodInts); byte prodBytes = testByte.Product(); Console.WriteLine(prodBytes); decimal prodDecimal = testDecimal.Product(); Console.WriteLine(prodDecimal); //testing Average Console.WriteLine(); Console.WriteLine("Testing Average-----------------------------------------------"); Console.WriteLine(); int averageInts = testInts.Average(); Console.WriteLine(averageInts); byte averageBytes = testByte.Average(); Console.WriteLine(averageBytes); decimal averageDecimal = testDecimal.Average(); Console.WriteLine(averageDecimal); //testing Min Console.WriteLine(); Console.WriteLine("Testing Min-----------------------------------------------"); Console.WriteLine(); int minInt = testInts.GetMin(); Console.WriteLine(minInt); byte minByte = testByte.GetMin(); Console.WriteLine(minByte); decimal minDecimal = testDecimal.GetMin(); Console.WriteLine(minDecimal); string minString = testString.GetMin(); Console.WriteLine(minString); //testing max Console.WriteLine(); Console.WriteLine("Testing max-----------------------------------------------"); Console.WriteLine(); int maxInt = testInts.GetMax(); Console.WriteLine(maxInt); byte maxByte = testByte.GetMax(); Console.WriteLine(maxByte); decimal maxDecimal = testDecimal.GetMax(); Console.WriteLine(maxDecimal); string maxString = testString.GetMax(); Console.WriteLine(maxString); }
public static void Main(string[] args) { int flightsCount = int.Parse(Console.ReadLine()); decimal[] flightsOverallIncome = new decimal[flightsCount]; for (int flight = 0; flight < flightsCount; flight++) { int adultsCount = int.Parse(Console.ReadLine()); decimal adultTicketCost = decimal.Parse(Console.ReadLine()); int youngstersCount = int.Parse(Console.ReadLine()); decimal youngestersTicketCount = decimal.Parse(Console.ReadLine()); decimal flightPerHour = decimal.Parse(Console.ReadLine()); decimal fuelConsumption = decimal.Parse(Console.ReadLine()); decimal flightDuration = decimal.Parse(Console.ReadLine()); decimal totalExpense = (adultsCount * adultTicketCost * 1.0M) + (youngstersCount * youngestersTicketCount * 1.0M) - (flightPerHour * fuelConsumption * flightDuration * 1.0M); if (totalExpense >= 0) { Console.WriteLine($"You are ahead with {totalExpense :F3}$."); } else { Console.WriteLine($"We've got to sell more tickets! We've lost {totalExpense:F3}$."); } flightsOverallIncome[flight] = totalExpense; } Console.WriteLine($"Overall profit -> {flightsOverallIncome.Sum():F3}$.\nAverage profit -> {flightsOverallIncome.Average():F3}$."); }
static void Main() { //Test StringBuilder.Substring StringBuilder stringBuilderInput = new StringBuilder(); stringBuilderInput.Append("01234 I have the simplest tastes. I am always satisfied with the best."); //get Substring StringBuilder substringOne = stringBuilderInput.Substring(5); StringBuilder substringTwo = stringBuilderInput.Substring(5, 28); StringBuilder substringThree = stringBuilderInput.Substring(33); Console.WriteLine(substringOne.ToString()); Console.WriteLine(substringTwo.ToString()); Console.WriteLine(substringThree.ToString()); //Test IEnumerable extensions List <int> testInts = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; byte[] testByte = new byte[] { 1, 2, 3, 4 }; decimal[] testDecimal = new decimal[] { 1.0m, 2.5m, 4.5m, 7.5m, 10m }; string[] testString = new string[] { "Some", " Text", " to", " test" }; //testing Sum Console.WriteLine(Divider("IEnumerable<T>.Sum")); Console.WriteLine(testInts.Sum()); Console.WriteLine(testByte.Sum()); Console.WriteLine(testDecimal.Sum()); Console.WriteLine(testString.Sum()); //List<int> empty = new List<int>(); //Console.WriteLine(empty.Sum()); //this will throw exception //testing Product Console.WriteLine(Divider("IEnumerable<T>.Product")); Console.WriteLine(testInts.Product()); Console.WriteLine(testByte.Product()); Console.WriteLine(testDecimal.Product()); //Console.WriteLine(testString.Product()); //this will throw exception //testing Average Console.WriteLine(Divider("IEnumerable<T>.Average")); Console.WriteLine(testInts.Average()); Console.WriteLine(testByte.Average()); Console.WriteLine(testDecimal.Average()); //Console.WriteLine(testString.Product()); //this will throw exception //testing Min Console.WriteLine(Divider("IEnumerable<T>.Min")); Console.WriteLine(testInts.Min()); Console.WriteLine(testByte.Min()); Console.WriteLine(testDecimal.Min()); Console.WriteLine(testString.Min()); //testing Max Console.WriteLine(Divider("IEnumerable<T>.Max")); Console.WriteLine(testInts.Max()); Console.WriteLine(testByte.Max()); Console.WriteLine(testDecimal.Max()); Console.WriteLine(testString.Max()); }