Programming Assignment 1
Due Monday, October 2
Based on an assignment created by Dr. Sarraille and
Problem 6 in Chapter 5 of our text book.
Write a program that employs a recursive function to
check a series of
strings to see if they are well formed expression.
The program reads a series of zero or more strings (strings are
white space) from standard input.
The program writes all its output to standard output. First the program
writes a heading/greeting message. Next, for each input string, the
goes to a new line of the output, echos (writes) the input string to
output, goes to a new line again, and prints a message telling whether
string is a well formed expression. Finally the program prints an exit
message and stops. There is no other output.
Discussion of Processing:
The following rule defines a well formed expression:
<dash> <word> |
<dot> = .
<dash> = -
Your solution to this problem must be "recursive" -- it must include a
recursive function that does all the significant work of
This problem is a little like one of the exercises in chapter 5 of
Carrano. You can get some ideas for a
solution there. In your solution code, you may want to use the
substr method of the string
See Appendix A of Carrano (Review of C++ Fundamentals) for
Your test script will count for about 15% of your grade on this
program. You need
to create a test suite with good data and code coverage.
What To Turn In:
One can solve this
problem with a very small program (e.g. just two functions,
including main). Do not start coding until you think of a simple
Here is the list of things you have to turn in:
- At the start of class on the due date, place the
following items on the "counter" in front of me:
Make sure that all of the code and script content shows on the paper.
Make sure all content is plainly readable and properly formatted.
- a hardcopy of your final version of the program source code,
- a hardcopy of your test script showing adequate testing of
- Upload to the homework
submission system before midnight on the due date:
Your final source code (example
format) and your test script. I will compile and test your programs
on the suns in the lab.