CS: c++ (Madlibs)


CS 002 - Assignment 1: Madlibs


Collaboration Policy

We encourage collaboration on various activities such as lab, codelab, and textbook exercises. However, no collaboration between students is allowed on the programming assignments. Please be sure to read and understand our full policy at: Full Collaboration Policy


Assignment Specifications

For this assignment you will create a madlib, constructing a story around several user inputs. Search Google for madlibs if you are not familiar with this concept. You are to come up with your own madlib, so let your imagination go wild!


Additional Knowledge

Examples of madlibs:www.madglibs.com orwww.wordlibs.com

Your Assignment

You do not need to create your own story, but do not just copy one of the examples. Find or create a short story of your own and convert it to a madlib similar to the examples.


However, to ensure you learn from this exercise, your madlib must have the following:


  • You must have a minimum of 10 inputs from the user. These inputs should all be stored as variables of type string. However, a single input must not be more than 1 word (or 1 number).

  • Your output must have at least 3 paragraphs, each paragraph separated by a blank line. Each paragraph must have at least 3 sentences.

  • Your output must have complete sentences with proper punctuation and word spacing.

  • No line of output should have more than 80 characters.

    • When testing your code I will never input more than 1 word answers.

    • I will always use inputs of 10 characters in length.

        • Take these things into consideration when determining where to put a newline character in your output so the output never has more than 80 characters in a single line.


        • With the 10 character inputs in the variable output locations, the output should try to get as close to the 80 character line limit as possible without exceeding it.  This means you should not have a line of 60 characters, as one or more words on the next line more than likely could have fit on that line without going over 80.  This rule does not apply to the end of a paragraph.

        • To help with determining correct output length we can utilize a dashed line of 80 characters.  To declare a string called measuringStick filled with all dashes we utilize this string definition statement:
          // create a string variable consisting of 80 dashes:
          string measuringStick(80, ‘-’);

          DO NOT COPY AND PASTE THE ABOVE, TYPE IT INTO Qt.You must output this line of dashes before and after your story (using cout).


Output Requirements

Every input should be followed by a blank line.  Your story should be separated by a blank line from your inputs and your story should be surrounded by a line of 80 dashes.

Here is a simplified example, the user input has been bolded and underlined for emphasis:

Please enter a profession: beautician


Please enter the last name of a President: Washington



First paragraph of story.


Second paragraph of story.


Third paragraph of story.



Formatting Help

Every line (except the last in a paragraph) must be as close to 80 characters long as possible (when all input words are 10 characters each). We test this by looking for both "too long" lines and "too short" lines. Here are some tips on how get the line length right:


Check your output line length in comparison to the 80 character dashed line:


  • Test your formatting with 10-character words: Each line should be as close to 80 characters as possible (except for the last line of a paragraph, of course), and never exceed 80.

  • Paragraphs should have a blank line between them.


Scoring Issues

When a story contains all long lines or all short lines, the resulting score will be a 0 for formatting as you cannot get points for formatting by not doing it at all!


    • 5 years ago
    • 8