Average Word Length problem C# test 3 and 5 fail
I think it have connection with rounding. When i use Math.Round i get 2 fails (test 3 and 5) but when use Math.Ceiling i have only one fail (in test 1) My code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace SoloLearn { class Program { static void Main(string[] args) { string sentence = Console.ReadLine(); List<char> word = new List<char>(); List<int> sum = new List<int>(); int i = 0; double result; while(i <= sentence.Length-1) { if (sentence[i].Equals(' ') || sentence.Equals(',') || sentence.Equals('.')) { sum.Add(word.Count); word.Clear(); i++; } else { word.Add(sentence[i]); i++; } } sum.Add(word.Count); result = Math.Round(sum.Average()); Console.WriteLine(result); //Console.ReadLine(); } } }