Question: You are to write a program that plays MadLib. You are to create a blank file, called madLibInput.txt. In this file, you are going to
You are to write a program that plays MadLib. You are to create a blank file, called madLibInput.txt. In this file, you are going to type: adjective food noun appliance verb food meat animal plant liquid color food adjective plant After each of these words, your player will write one word of that type. For example, when done, the first three lines of the file could read: adjective big food celery noun phone Provided with the HW is a file you will upload, called RawStory.txt. In this file is a story, but with several words missing. The missing words are represented by the character string $N$. These missing words will be replaced with the words your player entered in madLibInput.txt. Note that your player will not see RawStory.txt, but will just randomly choose an adjective, etc. The idea of a MadLib, is that these random responses will be used to replace the blanks ($N$), often resulting in a funny (or silly) story. Your program will write this store out to a file called MadLibStory.txt, which your player will read. Your C++ program will thus do the following. Open the input files madLibInput.txt and RawStory.txt. Also, open the output file MadLibStory.txt. Begin to read in RawStory.txt word by word, and writing out word per word the story to MadLibStory.txt. However, if a word read is the string $N$, read in the next word input from madLibInput.txt. Be careful as you need to read two words in, the word type (such as adjective), which you
will not use. Then read the word the user entered. Write this word out to MadLibStory.txt instead of $N$. Note that you will have to add spaces before (or after) words. The exception is punctuation. When the end of file of RawStory.txt is reached, close the files and invite the player to read MadLibStory.txt. Make a flow-diagram of your function first, which you will turn in. Use this to write your program.
RawStory.txt
Today I went to my favorite Taco Stand called the $N$ $N$ . Unlike most food stands, they cook $N$ and prepare the food in a $N$ while you $N$ . The best thing on the menu is the $N$ . Instead of ground beef they fill the taco with $N$ and cheese made from $N$ milk and top it off with a salsa made from $N$ . If that doesn't make your mouth run with $N$ , then you need to try the $N$ $N$ made with $N$ organic $N$ ! Now that is good!!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
