C++ Programming
CIT1154 - Assignment 5 Document Analysis C o nd i ti o n al s t a t e m e n ts, fu n c ti o n s, s c o p e, fi l e I/ O , s tr i ng s, v e c to r s
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.
Submission All parts of the submission are to be uploaded in Canvas by the due date. Refer to the style guide posted in Canvas!
1. Write and submit a C++ source code file that implements your solution. (.cpp) a. Your source code must contain appropriate internal documentation (comments) b. Your source code must be neatly formatted for readability.
2. Write and submit an external documentation file (.pdf) that documents your solution. a. Program summary b. Documentation of working features (may include screenshots or descriptions of tests) c. Description of any problems you tested that caused the program to break, but you could
not fix. (known issues)
- Description
- Submission