Question: in c++ #include #include #include #include using namespace std; void convertToLower(string& inputString); void countInstances(const string& searchWord, const string& sentence, int& uniqueInstanceCount, int& partInstanceCount); int main()

in c++in c++ #include #include #include #include using namespace std; void convertToLower(string& inputString);void countInstances(const string& searchWord, const string& sentence, int& uniqueInstanceCount, int& partInstanceCount); intmain() { ifstream input("text.txt"); string searchWord; cin >> searchWord; int uniqueInstanceCount =

#include #include #include #include using namespace std;

void convertToLower(string& inputString); void countInstances(const string& searchWord, const string& sentence, int& uniqueInstanceCount, int& partInstanceCount);

int main() { ifstream input("text.txt"); string searchWord; cin >> searchWord; int uniqueInstanceCount = 0; // count of unique instances int partInstanceCount = 0; // count of part-of-word instances

while(!input.eof()){ string sentence; getline(input, sentence); // Your code starts here

// Your code ends here }

cout

void convertToLower(string& inputString) { // Your code starts here

// Your code ends here }

void countInstances(const string& searchWord, const string& sentence, int& uniqueInstanceCount, int& partInstanceCount) { // Your code starts here

// Your code ends here }

You are required to write a program which accepts a search word from the user console, and also reads lines of text from the file "text.txt". Bo the search word and the text must be converted to lower case letter before analyzing the text so as to make the search case insensitive. Your code must have two functions. The first function convertToLower handles the conversion to lowercase. The second function countInstances can be used to: o count how many times the search word has uniquely and exactly appeared in the text. count how many times the search word has appeared in the text as part of another word. The program must report the number of unique exact matches, and the partial matches on two separate lines. Your code must be able to skip any empty lines in the file Assume the text has no punctuation marks, only spaces and apostrophes (1) Sample Case o Suppose the content of the file "text.txt" is: The foragers were FORBIDDEN from going to the forest to look for food This was enforced by giving fines of 500$ per violation Input: for Autant Type here to search BI E Input: for Output 1 4 Explanation The search word for only appears once in the text. However, it appears four times as part of the words foragers, FORBIDDEN, forest, and enforced. 1 2 3 #include #include #include #include using namespace std; 4 5 6 7 8 void convertToLower(string& inputString); void countInstances (const string& searchWord, const string& sentence, int& uniqueInstanceCount, int& partInstanceCount); 9 10 11 12 int main() { ifstream input("text.txt"); string searchWord; cin > > searchWord; int uniqueInstanceCount = 0; int partInstanceCount = 0; 13 14 // count of unique instances // count of part-of-word instances 15 16 17 while(!input.eof()) { Type here to search 1 DI 17 18 while (!input.eof()) { string sentence; getline (input, sentence); // Your code starts here 19 20 21 22 23 // Your code ends here 24 } 25 26 cout

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!