Write a program to implement Mad Lib®. According to Wikipedia, Mad Libs is a word game where one player prompts another for a list of words to substitute for blanks in a story; these word substitutions have a humorous effect when the resulting story is then read aloud. The program will prompt the user for the file that describes the Mad Lib®, and then prompt him for all the substitute words. When all the prompts are complete, the program will display the completed story on the screen.
The program will prompt the user for the filename of his Mad Lib®, allow him to play the game, then ask him if he wants to play another. Consider the following Mad Lib® with the filename madlibZoo.txt:
Zoos are places where wild [plural_noun] are kept in pens or cages [#] so that [plural_noun] can come and look at them . There is a zoo [#] in the park beside the [type_of_liquid] fountain . When it is feeding time , [#] all the animals make [adjective] noises . The elephant goes [{] [funny_noise] [}] [#] and the turtledoves go [{] [another_funny_noise] . [}] My favorite animal is the [#] [adjective] [animal] , so fast it can outrun a/an [another_animal] . [#] You never know what you will find at the zoo . [#]
An example of the output is:
Please enter the filename of the Mad Lib: madlibZoo.txt
Plural noun: boys
Plural noun: girls
Type of liquid: lemonade
Adjective: fuzzy
Funny noise: squeak
Another funny noise: snort
Adjective: hungry
Animal: mouse
Another animal: blue-fin tuna
Zoos are places where wild boys are kept in pens or cages
so that girls can come and look at them. There is a zoo
in the park beside the lemonade fountain. When it is feeding time,
all the animals make fuzzy noises. The elephant goes "squeak"
and the turtledoves go "snort." My favorite animal is the
hungry mouse, so fast it can outrun a/an blue-fin tuna.
You never know what you will find at the zoo.
Do you want to play again (y/n)? n
Thank you for playing.
Note that there is a tab before each of the questions (ex: “Plural noun:”)
Consider the following user's file called madLibFriend.txt:
There once lived a [adjective] [creature] who wished he were [emotion] . Because [#] of his [adjective] looks , no one wanted to be his [noun_(singular)] . Then [#] one day a [adjective] [noun] found the [creature] [#] and thought [{] I'll be his [noun] . [}] From [#] that [unit_of_time] forward, they were [emotion] .
Notice the following traits of the file:
Your program will not need to be able to handle files of unlimited length. The file is guaranteed to have the following properties:
The first part of the project is the design document. This consists of three parts:
Favorite car: Ariel Atom 3
First pet's name: Midnight