(Latest Revision: 10/05/2016)
SECOND CS 1500 SOLO PROGRAM: Using Multiway Decision to Suggest Stories
Your assignment is to write a program whose purpose is to input an integer
signifying a month of the year, and to output the title and author(s) of
a children's story that relates to the season in which the month (mostly)
falls.
Here is a list of the months, and the books to be suggested corresponding
to each month. (Note that there are only four books in total, one for
each season.)
- For months 1-3: "Dear Rebecca, Winter Is Here" by Jean Craighead George
- For months 4-6: "Bluebird's Nest" by Dorothea DePrisco
- For months 7-9: "Summertime in the Big Woods" by Laura Ingalls Wilder and Renee Graef
- For months 10-12: "Halloween Day" by Anne Rockwell and Lizzy Rockwell
You must write the program so the output has a very specific form and content.
Refer to this script to learn, in very
complete detail, everything there is to know about what the output of the program
should be, including the response that the program must give to every possible
integer input.
Make sure to
write the program so that it inputs only one integer.
(For example, don't put any loops into this program.)
When I test the programs of all the students in the class, I will need to use
special techniques (a script that utilizes redirection from prepared files of
input). In effect, another program will test your program, and the programs
of all your classmates. This requires that all the student programs behave exactly
the same way, especially when they read input.
TESTING AND CORRECTNESS:
Your program will lose significant credit if it doesn't work correctly on all
possible inputs. Your script must show that you tested for all of the types
of errors that the program is supposed to catch. (Refer to the script to gain an understanding of
which errors have to be caught, and how the program has to react to them.
Also, your script must show that you tested enough integer inputs to get all
the possible outputs - all the books, plus the error message too. With regard to
testing for bad input, your script must show a test for at least one integer
that is smaller than 1, and at least one integer that is greater than 12.
My procedures will test your program exhaustively.
DESIGN DETAILS:
For the number that your program inputs, use an int variable.
Use C++ if-else-logic or C++ if-logic to program the decisions that determine
what output statements the program writes in response to the integer the
user inputs. No switch statements are allowed. Without fail, read
all the assigned readings in your textbook up to and including section 3.2 (Multiway Branches) before you start designing the solution to this programming problem. Think about the different kinds of if-else logic the text book discusses. Try to figure out a non-complicated way of writing this program. If you get started and the program you are writing begins to get quite complicated, you are probably making things much harder than you need to. Ask me to have a look at your design in progress, if you like. Maybe I can give you some helpful suggestions that will make your job easier.
Whatever you do, keep on coming to class, to see discussion of this kind of C++ programming, and possible discussions of this assignment itself.
There are easy ways to do this assignment, and hard ways. The easy way is for the student to have the discipline to begin working on the assignment right away, to do a little bit of the work on it every day, and to ask me questions when they come up. Procrastinating is probably the worst approach. When it's a computer program, one can't "fake it." Either the program does what it's supposed to do, or it doesn't.
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 that 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, including proper
indentation.
(You can't put more than about 75 characters on any line, including
blanks. Tabs take up the space of numerous blanks, and it's not
possible to control how many. Don't put any tabs in your source
code. No Tabs!!) If the printer paper has
perforated edges
with holes for the "printer tractor," take those off before turning
in the hardcopy.
- Before midnight on the
due date
send me the following by e-mail:
- A copy of the source code (C++ code) with subject line:
CS1500Solo2Source
and
- A copy of your (filtered) script, with subject line:
CS1500Solo2Script
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.)