CIS 1057: Homework 7

Handed out: 10/12/10
Due: by 10am on 10/18/10
Email program to TA

Write a program that in a loop prompts the user to enter a text line and then reverses the line and prints out:

  1. The reversed line.
  2. The reversed line with:
    1. capital letters replaced by by lowercase letters,
    2. leading spaces removed,
    3. streaks of two or more spaces replaced by single spaces.
  3. OPTIONAL: One per line, indented by a tab, the tokens occurring in the line created in 2). [A token is a maximal sequence of non-white characters, i.e. ' ', '\n', '\t']

The loop is terminated when the user enters a line without tokens.

Here is an example of the interactions in a possible run:

Enter line [CR to exit] : Roses   are   VERY red
der YREV   era   sesoR
der yrev era sesor
	der
	yrev
	era
	sesor
Enter line [CR to exit] :    VioLETS ARE    Blue 
eulB    ERA STELoiV   
eulb era steloiv
	eulb
	era
	steloiv
Enter line [CR to exit] :

As a comment at the beginning of your program you should do a case analysis for this problem: problem statement, analysis, design, and testing.