Question: Programming language: C++ Please do not use vectors Software Guidelines/Rules You are not allowed to use anything beyond functions and strings for this assignment. In
Programming language: C++ Please do not use vectors
Software Guidelines/Rules
You are not allowed to use anything beyond functions and strings for this assignment. In particular, no data structures such as arrays and vectors! Since input data is arbitrarily large and we have no way of storing arbitrarily large data, you may need to open/close input files many times.
Part of your grade relates to how well you decomposed your problem into functions. A good decomposition will also save you much time since the alternative involves writing the same code many times.
You may find that grep helps you test your program on large input files.
Assignment
A sentence is a string that starts with a character or number, ends with a period, and contains no periods. Note that it will typically contain spaces, and we allow it to have any punctuation symbols.. The sentence's length is defined to be the number of words in the sentence
A word is a string that contains no spaces. Note that words in sentences may be separated by any number of spaces.
Inputs:
An input file named "sentences" that contains a sequence of sentences. The number of sentences as well as the length of each sentence may be arbitrarily long. There are no whitespace constraints - for example, two sentences may have multiple spaces between them, a sentence may or may not start on its own line, etc. However, you may assume that the characters in the sentences are all ASCII (so, no need to handle special Unicode characters).
An input file named "words" that contains a sequence of words, one per line. Words may be of arbitrary length but a precondition to main is that there are between 2 and 8 words in this file.
For purposes of this project, you may assume that the inputs contain no non-printable ASCII characters (so you don't need to test for that).
Assignment:
Write a program that produces the following outputs:
An output file named "match" that contains every sentence in file "sentences" with the first word in file "words". Each sentence should be on its own line.
An output file named "replace" that contains the same data as above, but with every occurrence of the first word of "words" replaced with the second word of "words".
An output file named "allwords" that contains every sentence in file "sentences" with each of the words in file "words" (not necessarily contiguous or in the same order). Each sentence should be on its own line and in the same order as in the sentences file.
Output messages to the screen in the following order (and using this exact text)::
sentences that match the first word saved in file match. The longest sentence matching the first word has words, and the 2nd longest has words. sentences that match every word saved in file allwords.
Note that you should handle the case where the two longest sentences are of the same length (unlike similar code we gave in class).
If there are any errors (including cases of missing files, etc.), output appropriate messages to cerr.
There are some additional rules that apply to all outputs:
All matches are case-insensitive - for example, the word "ate" is considered to match sentence "I aTe pizza".
Sentences in the output files should start in an upper case character (whether or not the input sentence did), but should preserve case otherwise.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
