public static void PartOne() { Console.WriteLine(); Console.WriteLine("ENTER A SENTENCE OR PARAGRAPH:"); string userSentenceInput = Console.ReadLine(); Console.WriteLine(); Console.WriteLine("ENTER THE WORD YOU WOULD LIKE TO SEARCH FOR"); string userWordInput = Console.ReadLine(); Counter newCounter = new Counter(userWordInput, userSentenceInput); bool emptyInput = newCounter.EmptyInput(); if (emptyInput) { Console.WriteLine("Please Re-Enter Your Selection"); PartOne(); } else { } string[] userInputArray = newCounter.SplitSentence(); newCounter.CountWords(userInputArray); Console.WriteLine(); Console.WriteLine("SENTENCE: " + userSentenceInput); Console.WriteLine("WORD: " + userWordInput); Console.WriteLine("WORD FREQUENCY: " + newCounter.WordScore); PartTwo(); }
public static void Loop() { Console.WriteLine("---------\nSentence:"); string sentence = Console.ReadLine(); Console.WriteLine("---------\nWord"); string word = Console.ReadLine(); Counter newWordCounter = new Counter(sentence, word); string[] sentenceArray = newWordCounter.SplitSentence(); newWordCounter.CountWords(sentenceArray); Console.WriteLine("Phrase contains " + newWordCounter.Count + " occurence(s) of the word '" + word + "'\n \nWould you like to try again with a new sentence? (yes/exit)"); string runAgain = Console.ReadLine(); if (runAgain.ToLower() == "yes") { Console.Clear(); Loop(); } }
public static void Main() { Console.WriteLine("Welcome to the Word Counter!"); Console.WriteLine("Enter the word you wish to count:"); string word = Console.ReadLine(); Console.WriteLine("Enter the sentence you wish to search:"); string sentence = Console.ReadLine(); Counter myCounter = new Counter(word, sentence); Console.WriteLine("I found {0} instances of the word {1} in your sentence.", myCounter.CountWords(), word); }