(Latest Revision: 09/30/2014)
SECOND CS 1500 SOLO PROGRAM: Translating Phone Letters To Digits
It can be helpful to get a phone number in a format like this:
Just call 1-800-FLOWERS
It's probably easy to remember that. However, when the time comes to dial the
number, it may slow a person down, having to hunt for which phone digits
correspond to F, L, O, W, E, R, and S.
Your assignment is to write a program whose purpose is to input a single
upper-case letter, and to output the corresponding phone digit.
Here is a table that tells what digit corresponds to each upper-case letter:
ABC ==> 2 DEF ==> 3 GHI ==> 4 JKL ==> 5
MNO ==> 6 PRS ==> 7 TUV ==> 8 WXY ==> 9
(Did you notice that it's an old phone? It has no Q or Z.)
The program has to print specific information, handle certain errors in a
specific way, and give its results using a certain format. Refer to this script to figure out all the details regarding
what the output should be when you run your progam.
Make sure to
write the program so that it inputs only one character.
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 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. (Read the sample script so you understand what all those
types of errors are.) Also, your script must show that you tested enough
upper-case letters to get all these digits as outputs: (2, 3, 4, 5, 6, 7, 8,
and 9). My procedures will test your program exhaustively.
DESIGN DETAILS:
For the character that your program inputs, use a char 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 character the
user inputs. No switch statements are allowed. Read the appropriate sections
of your text book to learn about if-else-logic and if-logic. Come to class to
see discussion of this kind of C++ programming.
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. Make sure all the code shows on the paper!
(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.) 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.)