CSCI 201 Fall 2000

Assignment 1


(A modification of course material used at Duke University)
  1. Write a program called sight.cpp that generates the following output (excerpts from a book by Marten and Carle). The words after the colon on each line, which are in italics, are entered by the user

      enter color and animal: brown bear
      enter another color and animal: red bird
      brown bear, brown bear, what do you see?
      I see a red bird looking at me.
      enter another color and animal: purple cat
      red bird, red bird, what do you see?
      I see a purple cat looking at me.
      enter another color and animal: blue horse
      purple cat, purple cat, what do you see?
      I see a blue horse looking at me.

    Note that the color and animal at the end of the second line of a verse is the same color and animal on the first line of the next verse. Also note the blank lines around each verse.

    If you don't include any functions other than main in your program you'll be duplicating a lot of code. In general it's not a good idea to duplicate code so you should almost certainly include functions to generate the output. Your program must prompt the user for four different animals as shown in the example run above. User-entered strings are separated by white space so two variables are needed to store "brown" and "bear" in the example above.


Note that 10% of your program grade is based on the readability of your program. This includes things like style, comments, and the naming of variables and functions. Make sure you include a comment at the top of each program with your name, course and purpose of the program specified.

// Name: YOUR NAME HERE // // Course: CSCI 201 // // Purpose: purpose of program here //

Submitting Programs

The program written for this assignment must be turned in by transferring the C++ source code file to your ftp directory for this class. Only the source code file (i.e., sight.cpp) should be turned in. You were shown how to transfer files to your class ftp directory in lab01, here is a quick repeat.