1. Engineering
  2. Computer Science
  3. 62 madlibs write a program that plays the game of...

Question: 62 madlibs write a program that plays the game of...

Question details

6.2: Madlibs

  • Write a program that plays the game of Mad Libs.
  • Your program must prompt the user to enter the following information as Strings in this order:
    1. A man's name
    2. A woman's name
    3. An adjective
    4. A second adjective
    5. A color
    6. A noun
    7. An animal
    8. A body part
    9. A holiday
  • After the Strings are entered, substitute the Strings into the below 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 a while, 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.java
  • Be careful of the spelling, including capitalization, and spacing
  • Note: Please use the single quote around the lines of dialogue (as shown above) rather than the double quote.
  • Note 2: Use only input.nextLine() to ensure that you read in all of the user input for each question.
  • 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 a noun: book

Enter an animal: duck

Enter a body part: leg

Enter a holiday: Valentine's

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 a while, 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, Larry!' they all cried.

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution