Example #1
0
        public static void GetWordCount()
        {
            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("Enter your word.");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            string wordInput = Console.ReadLine();

            Console.ForegroundColor = ConsoleColor.DarkGreen;
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("Enter your sentence.");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            string sentenceInput = Console.ReadLine();

            while (sentenceInput == "")
            {
                Console.ForegroundColor = ConsoleColor.DarkRed;
                Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                Console.WriteLine("Sorry please input a sentence to compare.");
                Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
                sentenceInput = Console.ReadLine();
            }

            RepeatCounter userInput = new RepeatCounter(wordInput, sentenceInput);
            int           count     = userInput.WordCount();

            Console.ForegroundColor = ConsoleColor.DarkBlue;
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            Console.WriteLine("Your word was " + wordInput + " and was used " + count + " times in the provided sentence.");
            Console.WriteLine("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
        }
Example #2
0
        public static void MainMenu()
        {
            Console.WriteLine("Welcome to WORDCOUNTER. We are able to calculate the nubmer of occurances for each unique word in your piece of literary art. Please type in the piece of literature that you would like stats for");
            string userInput = Console.ReadLine();
            Dictionary <string, int> wordCount = RepeatCounter.WordCount(userInput);
            string output = PrintDictionary(wordCount);

            Console.WriteLine(output);
            AgainMenu();
        }
        static void Main()
        {
            Welcome();
            Console.WriteLine("Please enter a word.");
            string Word = Console.ReadLine();

            Console.WriteLine("Please enter a sentence that uses that word at least once.");
            string        Sentence   = Console.ReadLine();
            RepeatCounter NeedsCount = new RepeatCounter(Word, Sentence);

            NeedsCount.ValidInputCheck(Word);
            NeedsCount.ValidInputCheck(Sentence);
            Console.WriteLine("Your sentence contains the word " + Word + " " + NeedsCount.WordCount() + " time(s).");
        }