Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
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". Both 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: 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 only spaces and apostrophes (') 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 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 #include
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started