Question: Write a program using c++ that analyzes the contents of a text file and produces the following results: 1) the number of words in the
Write a program using c++ that analyzes the contents of a text file and produces the following results:
1) the number of words in the text file
2) the number of unique words in the text file
3) the number of characters in the text file
4) the number of occurrences of each lower case letter in the alphabet
5) the number of occurrences of each upper case letter in the alphabet
6) the frequency of each letter, both upper case and lower case, in the alphabet.
The program should prompt the user for the name of a text file and then analyze the text to generate the results described above. If the file does not exit, the program should report the error and give the user another try to enter another file name. If the number of tries exceeds 5, the program should display an appropriate error message and exits.
#DEFINE _FILE_STAT_H_
class filestat { private: string fname; int wordCount; int uniquewordCount; int charCount; map
public: filestat(string s); filestat(string s, int tries); void update_char_occurrences(string txt);
}; #endif;
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
