New Skills Practiced (Learning Goals)
Problem solving and debugging.
User-defined functions.
C++ strings.
Design a program that will read a series of titles from an input file (via Linux redirection), one per line.
The titles will be in an unorthodox mix of upper and lowercase letters and words may be separated by more than 1 blank.
Reformat each title so that
the first character (if it is a letter) of each word is capitalized and all remaining letters are lowercase
each word is separated by exactly one blank space
For example, "thE CAT in tHe hat" becomes "The Cat In The Hat".
REQUIREMENTS
At least one function (in addition to main) must be used.
The string data type must be used.
Never use global variables.
Never use goto statements.
File can only be read one time.
The required output (displayed to the screen) from the program is
a list of the reformatted titles, one per line
ASSUMPTIONS
The input file will not be empty.
There will be one title per line.
Each title will consist of 1 or more words.
There will be no leading spaces before the first word in the title.
There will be at least 1 blank space between each word (there may be more).
There will be a linefeed after the last character of the last word in a title (no trailing blanks).
The program need only attempt to capitalize the first character of a word. For example, if a word in the title is "9TH", it should be reformatted to "9th". In other words, the program does not have to find the first letter in a word and capitalize it.
NOTES:
Make sure you choose enough test data to ensure that your program meets all the requirements.
Sample terminal session:
[keys]$ more data4ten
the 5TH wAVE
the cAT in thE HAT
onE fish two FISh red fISh bLuE Fish
[keys]$ g++ exercise10.cpp
[keys$ ./a.out < data4ten
The 5th Wave
The Cat In The Hat
One Fish Two Fish Red Fish Blue Fish