Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MAD LIBS Write a C++ program that will produce Mad Libs. Mad Libs are shortstori

ID: 3619219 • Letter: M

Question

MAD LIBS
Write a C++ program that will produce Mad Libs. Mad Libs are shortstories written
using words supplied by the person playing the game. Because theplayer is unaware of
the story, the words entered often create a funny result. Yourprogram is to read the
information provided in a file and get input from a user to producethe final story. The
program will allow the player to play multiple times withoutrerunning the program.
The main function of this program will define the needed variablesand call functions that
do all the work. There are to be no global variables. Use thestring class to store your data
(no c-strings except to open the file and when using atoi.) Main isalso a good place to
delete any memory that has been dynamically allocated.
You are required to write the following three functions (you mayhave additional
functions):
1. The getData function is to ask the player for the name of thefile (including the
extension) they would like to use. There are several **input filesavailable on the
course website for you to use. Make the maximum length of thisfilename 80
characters. This allows for an entire path and filename to beentered. Be sure to
test that the file opened correctly. If it did not open, print aninformative message
to the screen and allow the user to enter another filename.
After successfully opening the input file, this function is to readall the
information from the file and store it so it can be effectivelyused by other
functions.
The input file consists of a number indicating how many inputs arerequired by
the user for this Mad Lib followed by a list of what type ofentries are needed,
each on a separate line. This is followed by the story, with eachline of the story
on a separate line. No story has more than 32 lines. In the storywhere one of the
player's inputs is supposed to go, there is an * followed by a2-digit number. This
2-digit number represents the numeric order of the input requestedstarting with 1.
So *12 would indicate the 12th input is to be placed at this pointin the story.
An example of an input file:
3
adverb ending in -ing
famous singer
number
The *01 magician will be performing after *02.
There will be a *03 minute intermission.
This function will also request the needed information from theplayer and store
it so that it can be used by other functions. This function is todynamically
allocate an array of strings the exact size to store the player'sinput.
Store each line of the story in a single element of a stringarray.
2. The createStory function is to use the string functions outlinedin the text (pages
596-597) to combine the story from the input file and theinformation gathered
from the user to create the final story.
3. The printPretty function is to print the story to the screen.The output is to be
displayed nicely with a blank line between each line of the story.When a single
line of the story is longer than the default width of the consolewindow (80
characters), display the text on multiple lines making sure thecarriage returns are
at a space so that no word will be split between lines.
If the user entered dancing, Barbara Streisand, and 37, the outputfor the input file
shown above would be:
The dancing magician will be performing after Barbara
Streisand.
There will be a 37 minute intermission.
Display the user entered Mad Libs in all capital letters. 2%
The above output would look like this:
The DANCING magician will be performing after BARBRA
STREISAND.
There will be a 37 minute intermission.
Ask the user if they would like to save the mad lib story. If yes,prompt for
a file name and save the story.

This is the file that I would like to use.

 16
adjective
your town or city
adjective
plural noun
plural food
singular noun
a teacher
adjective
singular noun
friend
past tense verb
exclamation
singular body part
a favorite expression
your principal
plural noun
On the Track of Bigfoot
One *01 day our class went hiking along the *02 River. Like all *03 hikers, we were ready for any emergency. In our backpacks, we carried *04, *05, and one *06.
As we walked along the trail, *07 noticed a *08 footprint. "Do you think a *09 made these tracks?" *07 asked.
"No, but let's follow the them anyway," suggested *10.
We *11 for hours. Then I screamed, "*12! I think I see a huge *13."
"*14!" they heard someone say. It was *15.
"*15!" they screamed. "We thought you were a huge *13!"
"Do I look like a huge *13? Well, as long as you're all here, you can help me look for *16. There are lots of them here along the *02 River. We can take them back to school and study them under our microscopes."
"*14!" everyone said.





Explanation / Answer

please rate -thanks //Header Files #include #include #include using namespace std; //Function Prototypes bool getData(ifstream&,ofstream&); void createStory( ifstream&,ofstream&,string[],bool); int getWords(ifstream&,string[]); int main() {bool save; ifstream in; ofstream out; string words[50]; int numwords;     //Function Call     save=getData(in,out);     numwords=getWords(in,words);     createStory(in,out,words,save); in.close(); out.close(); system("pause"); return 0; } //Function Definitions int getWords(ifstream& in,string words[]) {int n,i; string word; in>>n; in.ignore(100,' '); for(i=0;i