Assignment 15
Due Tuesday March 6 at 11:20am on Canvas


Assignment 15.1: Madlibs (10 pts)
  • Write a program that plays the game of Mad Libs.
  • Your program must prompt the user to enter the following information as Strings and/or ints in this order:
    1. A man's name
    2. A woman's name
    3. An adjective
    4. A second adjective
    5. A color
    6. An integer
    7. A holiday
    8. A noun
    9. An animal
    10. A body part


  • After the strings are entered, substitute the strings into the following story and output the story to the console:

    The Haunted Tower

    One afternoon <man name> and <woman name> were walking down a(n) <adjective1> trail, looking for kindling for their campfire. The trees were <adjective2> and <color>, and there were colorful wildflowers all around. <man name> and <woman name> began to pick the wildflowers, and after <integer> hours, they went so far that they had wandered away from the trail.

    It started to get dark. <man name> began to get worried, but <woman name> seemed excited to have an adventure. "Look!"<woman name> said. "Do you see that tower? It looks like a <noun>!"

    "We're saved!" cried <man name>, who was relieved.

    Once they got closer, <man name> felt very uneasy again. It didn't look like the cozy little cottage <man name> had been imagining, but rather a big, spooky tower! It was about 14 feet tall, and it was covered with green ivy and moss. It was the creepiest thing <man name> had ever seen!

    <man name> said, "<woman name>, let's keep walking! There's no way I'm going into that tower! It looks haunted!"

    "Don't be such a(n) <animal>! We're going in. I think it looks safe to me!" said <woman name>.

    <man name> was so scared. He felt his <body part> chatter as <woman name> opened the door. All of a sudden, <man name> felt that he was not alone. He opened his eyes, prepared to see the worst. But instead, he saw all his friends and family inside the haunted tower! "Surprise! Happy <holiday>, <man name>!" they all cried.

    Note that you will need to decide where to insert newline characters into the output to make the text look like the above output.
  • The name of your file must be madlibs.cpp and your code must be in this file.
  • Be careful of the spelling, including capitalization, and spacing
  • Also be careful not to change the formatting of the above story in any way! You will want to preserve the original spacing and punctuation.
  • Upload your file to Canvas when you are finished.
  • Your output should look identical to the following, except user input will vary:


Welcome to Madlibs!

Enter a man's name: Larry
Enter a woman's name: Noreen
Enter an adjective: funny
Enter another adjective: amazing
Enter a color: red
Enter an integer: 5
Enter a holiday: Valentine's Day
Enter a noun: book
Enter an animal: duck
Enter a body part: leg


The Haunted Tower

One afternoon Larry and Noreen were walking down a(n) funny trail, looking for kindling for their campfire. The trees were amazing and red, and there were colorful wildflowers all around. Larry and Noreen began to pick the wildflowers, and after 5 hours, they went so far that they had wandered away from the trail.

It started to get dark. Larry began to get worried, but Noreen seemed excited to have an adventure. 'Look!' Noreen said. 'Do you see that tower? It looks like a book!'

'We're saved!' cried Larry, who was relieved.

Once they got closer, Larry felt very uneasy again. It didn't look like the cozy little cottage Larry had been imagining, but rather a big, spooky tower! It was about 14 feet tall, and it was covered with green ivy and moss. It was the creepiest thing Larry had ever seen!

Larry said, 'Noreen, let's keep walking! There's no way I'm going into that tower! It looks haunted!'

'Don't be such a(n) duck! We're going in. I think it looks safe to me!' said Noreen.

Larry was so scared. He felt his leg chatter as Noreen opened the door. All of a sudden, Larry felt that he was not alone. He opened his eyes, prepared to see the worst. But instead, he saw all his friends and family inside the haunted tower! 'Surprise! Happy Valentine's Day, Larry!' they all cried.