CSCI 201 Fall 2000

Assignment 1: Hush little baby, don't say a word

Program: Lullaby ,

For this assignment, you will create a program iteratively, at each part adding more to the program. Be sure to save the source code that you create for each part of the assignment (save them in seperate projects), because you will be required to turn in each version of the program.

Part 1

Consider the following output taken from the well known lullaby, that begins "Hush little baby, don't say a word,"


  Hush little baby, don't say a word,

  Daddy's gonna buy you a mockingbird,

  And if that mockingbird don't sing,

  Daddy's gonna buy you a diamondRing.

Write the program called lullaby1.cpp to generate the output above. Make sure there is a blank line between each phrase. Your program should consist of one function called main. This function requires no parameters.

Part 2

Modify lullaby1.cpp to be modular including at least one other function (besides the main function) with two parameters, one for an object (e.g., "mockingbird") and one for what the object "don't do" (e.g., "sing" for the mockingbird). Call the modified program lullaby2.cpp. The program lullaby2.cpp should produce the same output as lullaby1.cpp.

Part 3

Modify lullaby2.cpp to produce a program that prompts the user for input that will be used in the lullaby; save the modified program as lullaby3.cpp. Your program must prompt the user for three different objects and object failures as shown in the example run below. User-entered strings are separated by white space so two variables are needed to store "mockingbird" (the object) and "sing" (the failure) in the example below.

  Hush little baby, don't say a word,

  enter object and failure: mockingbird sing

  Daddy's gonna buy you a mockingbird,

  And if that mockingbird don't sing,

  enter another object and failure: diamondRing shine

  Daddy's gonna buy you a diamondRing.

  And if that diamondRing don't shine,

  enter another object and failure: silverMine pay

  Daddy's gonna buy you a silverMine.

  And if that silverMine don't pay,

Submitting Programs

The programs written for all 3 parts of this assignment must be turned in by transferring the respective C++ source code file to your ftp directory for this class. For each part of the assignment, only the source code file (i.e., lullaby1.cpp, lullaby2.cpp and lullaby3.cpp) should be turned in and the programs must have exactly those names.