CIS071 Lab04 – Drawing Stick Figures Using Functions              DUE: (Noon, Wed, Sep 27, 2006)


 

PROBLEM

You should write a single program called display_figure.c  that:

·         asks a user to choose one of the 3 figures (John, Mary, or Beldar) to be displayed

·         displays the chosen figure

The stick figures are presented below (observe that all figures consist of a few simple geometric shapes).

 

               *                       *                       *

             *   *                   *   *                    * *

            *     *                 *     *                  *   *

             *   *                   *   *                  *     *

               *                       *                   *********

           *********                   *                       *

           *       *                  * *                    *   *

           *       *                 *   *                  *     *

           *       *                *     *                  *   *

           *********               *********                   *

               *                       *                       *

              * *                     * *                     * *   

             *   *                   *   *                   *   *

            *     *                 *     *                 *     *  

             John                    Mary                    Beldar

 

INSTRUCTIONS
1. Make a new directory (e.g. mkdir Lab04) and include it in the default path (e.g. cd Lab04).
2. Use pico to create file display_figure.c.

3. The user should be prompted to choose one of the 3 figures by a display that reads as:

Welcome to the figure plotting program!

Please choose an integer between 1 and 3 to plot a figure:

1: plot John

2: plot Mary

3: plot Beldar

4. The program should read a number entered by the user and plot the appropriate figure. To do this, you should use the if selection statement. For example:

if (figure == 1) {

   /* plot figure of John */

   ...

}

else if (figure == 2) {

   /* plot figure of Mary */

   ...

5. If user enters something other than 1, 2, or 3, inform the user that selection is not valid and exit the program without displaying a figure.

6. Your program should contain at least 4 functions named:

plot_circle(), plot_square(), plot_triangle(), plot_legs()

These functions should be used to plot the selected figure. For example, to plot Beldar, you could write:

plot_triangle();

plot_circle();

plot_legs();

7. Compile the program and generate an executable file display_figure.
8. Test this program to make sure that it works correctly. Perform several test runs by typing several valid and invalid display selections.

 

DELIVERABLES

Use the “Pine” email facility to email the program to the TA. Subject of your email should contain your name, course title, and lab number (for example: Slobodan Vucetic, CIS071, Lab4) and attach file display_figure.c. Be sure to include the proper documentation at the beginning of the program (see Lab03 assignment) and use comments throughout the program. In the main body of the email, discuss briefly about the robustness of your program (does it work correctly under normal conditions, and how easy it is for a user to break it). Also, attach the outcome of test runs of your programs to the main body of the email.