(Latest Revision: 10/27/2000)
Recursion: A Program That Makes Palindromes From Lines of
Text
PRELIMINARIES:
You need to read chapter two of Carrano before you begin this
assignment. You also need to read the directions and examples
here:
http://shalim.csustan.edu/~john/Classes/General_Info/progAsgRules/
THE ASSIGNMENT:
Take a look at
this script
of me running a program.
Your assignment is to write a program that works like the
program illustrated by the script.
INPUT:
The program must read a series of lines of text from standard
input.
The program must be able to input any series of lines of text
-- no matter how long the lines happen to be and no matter how
many lines there are. (That includes blank lines and the case
where there are no lines at all in the series.)
OUTPUT:
The program writes one line of output for each line of input.
The line of output corresponding to a given line of input
consists of three items printed one after the other:
- The characters of the input line,
- A single hyphen, and
- the characters of the input line in reverse order.
The output for each line of input is a palindrome. A
palindrome is a series of characters that reads the same
backwards or forwards. Thus the program you will write is a
palindrome-maker.
PROCESSING:
One of the goals of this assignment is to give you practice
using recursion. You must therefore write a
recursive function that inputs one line of text
from standard input and writes the required items to standard
output. Your program must call this recursive function to
produce the specified output for each line of input.
HELP AND HINTS:
The problem of writing the recursive function that makes the
palindromes is very similar to problem(s) that Carrano discusses
in our textbook, and so in order to get some hints that will
help you get started on the program, please check out pages
61-66.
We can discuss other details of the assignment in class.
WHAT TO TURN IN:
Send the following two items to me by e-mail before midnight on
the due date:
- A final-level source file. Use this subject line:
CS2500,prog2.f
- a final-level test script. Use this subject line:
CS2500,script2.f
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.
DUE DATE:
For the due date, see
the class schedule.