Answered step by step
Verified Expert Solution
Link Copied!

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

image text in transcribed

image text in transcribed

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 2 #include 3 #include 4 #include 5 using namespace std; 6 7 void convertToLower(string& inputString)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions