Write a modular program to ask the user for a file to read


Assignment: Document Analysis

Conditional statements, functions, scope, file I/O, strings, vectors

Description

Write a modular program to do the following:

• Ask the user for a file to read.
• Read through that file and count all the occurrence of each word that is found.
• Output this list of words (along with their counts) to the screen.

At a minimum, there should be:

• Since we have no idea of the amount of words that the file might contain a vector is the natural choice for data storage. Use one vector to store the word and another vector to keep track of how often the word occurs. We would call these parallel vectors since the word at position five would have its count stored in the fifth position of the second vector.

• A main()function that controls the operation of the program

• A findWordPosition() function that takes a vector and a string as parameters and returns the position that the string occupies in the vector. If the string is not found return -1. This would be useful to see if the word has already been added. When comparing words please ignore all case.

For example: barry would match Barry or BARRY or baRRy.

• A addWord() function that takes a string and two vectors as parameters. Store the new word in the vector and in the parallel vector set the count to 1.

• A reportToScreen() function that takes two vectors (words and the count) as parameters and displays 3 columns of words followed by their number of occurrences. Note: If you calculate and use the size of the largest word you can be sure that your columns will stay aligned.

Request for Solution File

Ask an Expert for Answer!!
Programming Languages: Write a modular program to ask the user for a file to read
Reference No:- TGS02957459

Expected delivery within 24 Hours