Question: write a C++ program which reads and processes a text file. Your C++ program should: 1. Read the name of the text file from the
write a C++ program which reads and processes a text file.
Your C++ program should: 1. Read the name of the text file from the console. 2. Read in a text file line by line or word by word 3. The file content must be converted to a sequence of words, discarding punctuation and folding all letters into lower case. 4. Store the unique words and count the occurance of each word. 5. The words should be ordered by decreasing count and alphabetically. (This ordering may be achieved as the words are read in, partially as the words are read or at the end of all input processing.) 6. Output the first ten words in the sorted list, along with their counts. 7. Output the last ten words in the list, along with their counts.
You must choose appropriate data structures and algorithms to accomplish this task. Note: in the context of this assignment, appropriate choices will be efficient and will not use excessive instructions or data. Note: where a punctuation mark appears between two letters, the sequence is to be treated as a single word. Thus, can't will become cant they'll will become theyll and loop-hole will become loophole.
Standard libraries of data structures and algorithms such as STL may not be used
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
