Question: The program must read standard input, collect a list of unique words, and print them in alphabetical order with counts of occurences of each word.
The program must read standard input, collect a list of unique words, and print them in alphabetical order with counts of occurences of each word. A word is a sequence of letters, lowercase or uppercase (including mixed), and it must be translated into lowercase letters only before including in the list of words.
Input
The standard input includes an arbitrary text. You can assume that there are no more than 10,000 unique words and the total length of all unique words is not more than 100,000 characters. You can also assume that no word is longer than 80 characters.
Output
Your program must print words in an alphabetical order, one word per line. After each word, there should be a space and the number of occurences of the word.
Sample input and output are given below:

Sample Input This is an example Sample Output an 7 example 2 is 3 More words: an is AN ExamplE-is An7aN an AN more 1 this 1 words 1 Sample Output, with visualized whitespace an 7 example 2 more 1Ln this 1n words 1m Note:- is a space, and Ln 1S a newline character. Sample Input This is an example Sample Output an 7 example 2 is 3 More words: an is AN ExamplE-is An7aN an AN more 1 this 1 words 1 Sample Output, with visualized whitespace an 7 example 2 more 1Ln this 1n words 1m Note:- is a space, and Ln 1S a newline character
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
