Suppose we have a text file that has been slightly modified. The modifications have removed all punctuation and eliminated all uppercase letters. Write a program that examines the words in this file and displays a table of information about them. A word is to be regarded as any sequence of consecutive characters separated from other character sequences by white space. For words of each possible length, the information to be displayed is the number of distinct words of that length in the file, the number of times the most frequent word of that length occurs, and the most frequently occurring word of that length. If there are no words in the file of a specific length, nothing should be displayed for that length. If there is more than one word whose frequency is equal to the highest for a specific word length, the table should show the first such word that appears in the file.
The program should prompt for the name of the file, then read it and display the table of information. The file questions.txt is provided for you to practice on. This file's table is shown below.
Length Distinct Frequency
Most Frequent
1
15 56 a
2
33 74 of
3
58 141 the
4
98 25 more
5
87 17 state
6
86 11 county
7
89 17 numbers
8
83 50 students
9
59 13 admission
10
67 21 department
11
25 10 departments
12
17 6
pennsylvania
13
17 16 matriculating
14
2 2 matriculations
15
3 2 recommendations
This indicates that there are 15 distinct
one-character words and 'a' is the most frequent, occurring 56 times.
Also, there are 33 distinct two-character words and 'of' is the most frequent,
occurring 74 times. And, so on.