Question: To submit your answer, please copy and paste your code below. In this activity, well use C# to write a Mad Libs word game. Mad

To submit your answer, please copy and paste your code below.

In this activity, well use C# to write a Mad Libs word game. Mad Libs are short stories with blanks for the player to fill in that represent different parts of speech.

The story has been provided for you, but it will be up to you to complete the following:

  • Prompt the user for inputs.
  • Print the story with the inputs in the right places.

Step 1: Begin by completing the multi-line comment that describes this program.

Step 2: Inform the user that the program is running. Before the string story, print a message to let the user know that Mad Libs has started.

Step 3: Give your story a title. Change the value of the variable title to a title that you like.

Step 4: Take a look at the string variable named story. It is set equal to a string that contains our story.

Step 5 : Creating the variables

Now, start creating the variables that we will use in our story. Make sure to declare all of your variables above the variable story.

Ask the user to input a name for the main character, and store the users input in a variable with a string type:

 

Console.Write("Enter a name: "); string name = Console.ReadLine();

 

(Note: Its good practice to use short, but descriptive variable names.)

Ask the user for three adjectives.

(adjectives describe a noun, like a color (blue), or feeling (silly), texture (soft).) Ask the user for input three separate times. Store each adjective that the user inputs into variables with descriptive names

Ask the user for one verb.

(A verb is a word that represents an action, like sit, eat, sleep) Ask the user to input a verb and store their response in a variable.

Ask the user for two nouns .

A noun is a person (girl), place (cabin), or thing (toaster).

Ask the user to input two nouns. Store each noun in its own variable.

Ask the user to input one of each of the following and save the inputs into different variables.

  • An animal
  • A food
  • A fruit
  • A superhero
  • A country
  • A dessert
  • A year

Step 6: Using String Interpolation Next, insert all of the users inputs into the blank spaces of the story using string interpolation.

Put a $ in front of the first quotation mark " in story and replace each underscore _ with a set of empty braces{}.

Write the names of each variable inside of the brackets.

Heres the order that they should appear in:

  • Name
  • First adjective
  • Second adjective
  • Animal
  • Food
  • Verb
  • First noun
  • Fruit
  • Third adjective
  • Name
  • Superhero
  • Name
  • Country
  • Name
  • Dessert
  • Name
  • Year
  • Second noun

Step 7: Write a line of code that prints out the completed story to the terminal.

program.cs file
using System;
namespace MadLibs
{
class Program
{
static void Main(string[] args)
{
/*
This program ...
Author: ...
*/
// Let the user know that the program is starting:
// Give the Mad Lib a title:
string title = "TITLE";
Console.WriteLine(title);
// Define user input and variables:
// The template for the story:
string story = "This morning _ woke up feeling _. 'It is going to be a _ day!' Outside, a bunch of _s were protesting to keep _ in stores. They began to _ to the rhythm of the _, which made all the _s very _. Concerned, _ texted _, who flew _ to _ and dropped _ in a puddle of frozen _. _ woke up in the year _, in a world where _s ruled the world.";
// Print the story:
}
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!