CSCI 201 Spring 2001

Assignment 1: The wheels on the bus (a modification of problem 2.5 in your text)

For this assignment, you will create a program iteratively, at each part adding more to the program. This is similar to the procedure that you should use to write any program. The difference is that, in the case of this assignment, you need to save the source code created as you iteratively refine your program. More specifically, save the source code for each part of the assignment described below (save them in separate projects), because you will be required to turn in each version of the program.

Part 1

Consider the following verses from the children's song called "The Wheels on the Bus":


the wheels on the bus go round and round
round and round
round and round
the wheels on the bus go round and round
all through the town

the doors on the bus go open and shut
open and shut
open and shut
the doors on the bus go open and shut
all through the town

the people on the bus go in and out
in and out
in and out
the people on the bus go in and out
all through the town

Write a program called bus1.cpp to generate the output above. It should look exactly as it does above so make sure there is a blank line between each verse. Your program should consist of one function called main. This function has no parameters.

Part 2

Modify bus1.cpp to be modular including at least one other function (besides the main function) with three parameters:

  1. the object (e.g., "people")
  2. the first part of how the object moves (e.g., "in" in the case of the object "people")
  3. the second part of how the object moves (e.g., "out" in the case of the object "people").
Call the modified program bus2.cpp. The program bus2.cpp should produce exactly the same output as bus1.cpp.

Part 3

Modify bus2.cpp to produce a program that prompts the user for input that will be used in the song; save the modified program as bus3.cpp. Your program must prompt the user for three different objects and object movements as shown in the example run below. User-entered strings are separated by white space so three variables are needed to store the object and its two movements, as shown in the example below.

  Let's sing three verses of the song, Wheels on the Bus.  
  Please enter a bus object: wheels
  how does this object move, enter two adjectives: round round

  the wheels on the bus go round and round
  round and round
  round and round
  the wheels on the bus go round and round
  all through the town

  Please enter a bus object: doors
  how does this object move, enter two adjectives: open shut

  the doors on the bus go open and shut
  open and shut
  open and shut
  the doors on the bus go open and shut
  all through the town

  Please enter a bus object: people
  how does this object move, enter two adjectives: in out

  the people on the bus go in and out
  in and out
  in and out
  the people on the bus go in and out
  all through the town

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., bus1.cpp, bus2.cpp and bus3.cpp) should be turned in and the programs must have exactly those names. You were shown how to transfer files to your class ftp directory in lab01, here is a quick repeat.