(This assignment is adapted from one that appears in A
Computer Science Tapestry by Owen Astrachan)
(
Latest Revision:
11/03/2004
)
FOURTH CS 1500 SOLO PROGRAM
Totem Pole
Assignment: Writing A Simple Loop
OBJECTIVE:
The purpose of this programming assignment is to give you practice writing and
using loops in your programs.
THE ASSIGNMENT:
Basically, your assignment is to write a program that gets an integer N from
the user and then draws N "heads" in a stack that looks like a totem pole.
INPUT, OUTPUT, AND PROCESSING:
The program must begin by writing some information explaining the purpose of
the program and a general description of how to use the program.
The program must then prompt for and read the number N.
After getting N, the program must do some error-checking. If N is not between
1 and 10, inclusive, then the program must output an appropriate error message
and stop. If N is within the legal range, then the program must draw the head
N times. After drawing the heads, it must draw a little "base" so that it
looks like the heads are standing on something.
EXAMPLE OUTPUT:
Examine the
sample script
to get an idea of how it should look when you run the program.
DESIGN:
As before (and always) I expect you to employ good principles of top-down
design. I will take off a lot of points if you do not create a program that
uses functions appropriately. I suggest that you employ a function to write
the directions, a function that draws the head, and a function that draws the
base. Your program must have at least four functions, including the main
function. Don't forget that each function is required to have a header
comment that explains the purpose of the function.
TESTING:
I expect you to make a test script for the program that shows good data
coverage. I discussed this concept in class. The idea is to test a
representative sample of inputs, and to test at and near boundary data values.
It is your responsibility to devise and carry out good tests. It is certainly
not enough if you just duplicate the tests done in my sample script. I will
take off a lot of points if you do not perform adequate testing.
WHAT TO TURN IN:
You will be sending me two e-mail messages. Please follow these
rules:
- Always send me e-mail as plain text in the main message body.
Never send me attachments.
- Always use the exact subject line I specify for each
message. (I often get hundreds of e-mail messages in a week. The
subject line allows me to find and sort messages.) You will lose a
significant number of points on the assignment if you use the wrong
subject line.
- Be very careful when you send the e-mail. You may use the
instructions in your
Hello World! lab excercise
for guidance. Of course, you will need to make the obvious changes to
those directions -- you have to use the correct subject line and
filename.
- Always send yourself a copy of each e-mail message you send to me,
check immediately to see if you receive the message intact, and
check within a few minutes to see if you have received e-mail notifiying
you about an undeliverable message. You are
responsible for sending e-mail correctly.
Here is the list of things you have to turn in:
- At the start of class on the
due date
place the following item on the "counter" in front of me:
- a hardcopy (printed listing) of your program (the C++
source code). Make sure all the code is properly
formatted and that it all shows on the paper.
- Before midnight on the the due
date send me the following by e-mail:
- A copy of the source code (C++ code) with subject line:
CS1500,Solo4,source, and
- a (filtered) script, with subject line CS1500,Solo4,script,
showing the results of several runs of the program illustrating
- its results on all appropriate boundary values,
- its results on a representative sample of inputs that are "out
of bounds," and
- its results on a representative sample of inputs that are well
within bounds.
Note that there are no spaces in the subject lines given. It is important
that you do not insert any spaces. My e-mail address is:
john@ishi.csustan.edu
WHEN IS THIS ASSIGNMENT DUE?
Look for the due date in
the class schedule.
(It's at the top level of the class directory.)