In this project, you will write a program that analyzes a text file and counts t
ID: 3624938 • Letter: I
Question
In this project, you will write a program that analyzes a text file and counts the number of times a word appears (a.k.a. the word’s frequency). When the program completes, it dumps each word and its frequency in order of most frequent to least frequent. For example, if the file contained the followingsentence:
It was the best of times, it was the worst of times
The output of the program would be:
it 2
of 2
the 2
times 2
was 2
best 1
worst 1
Note the following things about the output:
? Capitals were replaced with lower case.
? Punctuation was discarded (no comma in output).
? Words with the same count are sorted alphabetically.
? The most frequently occurring words appear first.
Explanation / Answer
use an array to store the count and the term, use a nested for loop to count the words and check for cases. you need to set up a compare in order to increment the word count.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.