project for computer science

0 comments

Program Information

Create a program which will read a phrase from the user and create a framed version of it for printing. For example, the phrase “hello world”would always result in:

   *********
   * hello *
   * world *
   *********

Whereas the phrase “the sky is falling”might be:

   ***********
   * the     *
   * sky     *
   * is      *
   * falling *
   ***********

Or:

   ***********
   *   the   *
   *   sky   *
   *   is    *
   * falling *
   ***********

Or even:

   ***********
   *     the *
   *     sky *
   *      is *
   * falling *
   ***********

Depending on whether or not the user asked for left, centered, or right justification — respectively — of the phrase’s words within the frame. Note how the frame exactly fits the phrase based on the longest word within. Neat, eh? (Makes “Hello World” seem like a bad test case, doesn’t it?)

The phrase “O | -+- | /-“when centered would become:

    *******

About the Author

Follow me


{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}