Write a program that reads a report (running text), issues warnings on style with the following features.

Statistics A statistical summary is prepared for each report processed with the following information:

  • total number of words in the report;
  • number of unique words;
  • number of unique words of more than four letters;
  • a listing of the special words with the number of times each was used in the report.

Style Warnings Issue a warning in the following cases:

  • Word used too often: List each unique word of more than four letters if its usage is more than 5% of the total number of words of more than three letters.

Run Summary At the end of the run the special words are written to the file with the number of times each was used during the run of the program.

Input

From the keyboard:

1. The name of the file containing the text to be analyzed

2. List of special words

From the file:

The report to be analyzed; ended by < eof>. Allow the user to continue with another file name or quit.

Output

1. For each report being analyzed write the following information to a file.

  • The name of the file
  • A listing of the file
  • The statistical summary of the report (See statistics above).
  • The style warnings given (See Style Warnings above.)

2. An alphabetical listing of the special words one per line with the number of times each was used throughout the run of the program.

Data Structures

1. A list to contain the special words

2. A list of unique words in the report, created as the file is read. If a word is not in the list, put it there. If it is, increment a counter showing how many times the word has been used.

Word : Sequence of letters ending in a blank, a period, an exclamation point, a question mark, a colon, a comma, a single quote, a double quote, or a semicolon. Numbers do not appear in the words; they may be ignored.

Unique word: Words that are spelled the same, ignoring uppercase and lowercase distinctions.

Sentence : Words between end of sentence markers or the beginning of the report and the first end of sentence marker.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.