Question: Objective: Write a program that searches for specified words hidden within a matrix of letters. 1. Ask the user for the name and location of

Objective: Write a program that searches for specified words hidden within a matrix of letters.

1. Ask the user for the name and location of a file to read; this file will contain the Word Search puzzle. Read the file. The may contain comments lines (they will start with a # symbol), data lines, and blank lines. The data in the file will first specify the dimensions of the matrix (e.g., 20 30). These two numbers specify the number of rows in the matrix and then the number of columns in the matrix.

2. Following these two numbers,there will be a number of rows of letters. These letters should be read into your matrix (a 2D array of chars) row by row, column by column.

3. Following the rows of letters,there will be some number of words/phrases that might or might not be hidden within the matrix. You are to search for these words/phrases and report 1) whether or not a given word/phrase is found within the matrix, and if so, 2) the starting coordinates of the word/phrase and the direction in which you found it, e.g., N, NW, SE, etc.

4. Search for each word (name, title, phrase, etc.) one at a time (i.e., read a word/phrase,search for it, report the results, and then read the next word/phrase from the file). Continue until all words/phrases have been searched for and reported.

5. You might want to start by creating your own file of data. You can start with a small matrix size (say 5x5) and your own hidden words. When youre ready,start testing one or more of the files Im going to upload to eLearning for your use. I suggest starting with the Comedy Movies puzzle called ComedyMovies-partial.txt. Once you can process this puzzle correctly, you can try other hidden-word puzzles.

6. Provide for fault-tolerance when trying to open the input file. If it doesnt exist or cant be found, tell the user. Also, tell the user the name of the file that cant be found/opened. Then give the user a chance to enter another file name and try to open that file. Continue until you either find and open the file or until the user types something like quit or exit. If you feel comfortable doing so, use the perror function to report the systems error message; then report your own error messages. Make sure your program can handle bad file names and/or non-existent files.

7. Dont report success or failure for each word as you go. Instead,report only words that are found, their locations, and their directions; but for words that are not found,shove them into a vector of strings and wait until youve searched for all words before reporting the words that werent found and then finally quitting. Thus, you will have all successfully found words appear first--along with their coordinates and their direction -- and then the words that werent found will be listed at the end.

8. Report the indices where movies are found in human-speak, not C/C++ speak. (See the example output at the end of this file. Dont report coordinates using 0-based index numbers.)

9. Assume that words/phrases can appear more than once in the matrix; so you may find and report on a given word more than once.

10. Dont wrap around the edges of the matrix. Instead, if you hit an edge while searching, assume the word isnt in the matrix. To be extra clever, you could also check for length issues before searching in a given direction if you want to, or you can start traversing a direction and check for out-of-bounds errors as you go; either way works fine, but the first way is a bit cleverer. IF you use that method, please, please make a note of this in your header comments in the source file.

11. You could add a Boolean variable that controls whether you search for multiple or just single occurrences within the matrix. This is optional, but please consider adding it. Set it to multiple for your final run and for the output you submit to eLearning.

12. For extra fun, consider adding an interactive capability to your program that asks the user to enter additional words to search for in the matrix once youve searched for all words in the data file.

13. For even more fun, consider adding a capability to advance to another hidden word puzzle once youve finished with the current one. That is, you could ask the user if theres another puzzle to process. If not, just exit; but if so, then just repeat the above process.

PROGRAM MUST BE ABLE TO READ IN FILES SUCH AS THE ONE BELOW:

# Here is the complete word search puzzle for the # Comedy Movies puzzle. Note that it is larger than # the file I distributed with the homework assignment, # so you should be able to find many more movies in this one. # You might test this file with your homework to see # what results you get. I believe you should find most of # the movies, but there are three that you won't find. The # "zzzzz" on is in there just for test purposes to see what # your program does when it can't find a particular movie. 18 18 SCFRBOBROBERTSLOKL TNLESREKCILSYTICRL AOEPOBLRUAECHBUDEA RITOTHEYOMTOLBATPH LTCMWRGIFMLBEEIBEE LCHAIBAONILLAURGEI AEKNLULDDGCISLHKLN MLCTILLAINTAGOLHSN AEUDALYCUNZHSYLOSA CRRURDBHSAGTEOPLUS LOTCLULHLLBPCRAPLA UMSKIROPOULALPEAAK EHNSAHNNSTLASACCEH LSOORADTEHSHBKCROA EUOUFMEMECOHETHEER SRMPARTRBTAROSAASV SLEISTOOTHERUTLESE NATTAHNAMSEYSLSSMY #Movie Titles to Search For ALL OF ME ANNIE HALL BABE BEING THERE BIG BOB ROBERTS BULL DURHAM CARS CATBALLOU CITYSLICKERS CLERKS CLUELESS DUCK SOUP ELECTION FLETCH GHOSTBUSTERS HAPPY GILMORE HARVEY HOLIDAY HOTSHOTS LEGALLY BLONDE LIAR LIAR LOCAL HERO MALLRATS MANHATTAN MEATBALLS MOONSTRUCK NAPOLEAN DYNAMITE OH GOD PLAZA SUITE RAISING ARIZONA REPO MAN RUSHMORE SHREK SLACKER SLAP SHOT SLEEPER THE RUTLES TOOTSIE TRADING PLACES UNCLE BUCK YES MAN #This movie won't be found. zzzz # And here's one little palindrome for testing. It's a movie # title not of a comedy but of a very famous robot movie. # Your program might find it twice depending # on whether you check for more than one existence of a movie. RUR

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!