Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume a file named words. txt exists. The file contains exactly 5 0 lines, and each line contains a single word. Some of the words

Assume a file named words. txt exists. The file contains exactly 50 lines, and each line contains a single word. Some of the words appear only once in the file, but some of them appear two or more times. For this project, you will write a program that reads the contents of the file and counts the number of times each unique word appears in the file.
The program should use a structure that has two members:
A string to hold a word from the file
An int to hold the number of times the word appears in the file
The program should create an array of the structures and use the array to hold all the unique words from the file and the number of times each word appears. After the program has processed the contents of the file, it should step through the array and display each unique word from the file, followed by a space, followed by the number of times that word appears in the file.
Note: Your program should disregard case when processing the words from the file. For example, the words "eagle" and "EAGLE" should be considered equal.
The following sample run shows an example of the expected output of the program. In this sample run, the program found 10 unique words in the file. The word "option" appears 1 time, the word "eagle" appears 1 time, the word "popular" appears 4 times, and so on.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

=+Are you surprised how much caffeine you ingest regularly?

Answered: 1 week ago