For example:
English | Pig Latin |
---|---|
hello | ello-hay |
strange | ange-stray |
and | and-ay |
For convenience, we will not translate one letter words. But you may if you wish.
For the purpose of this program, vowels are the set {a, e, i, o, u, y}. Consonants are all other letters that are not vowels, and include ' and -.
Your program should prompt for a file to open, then translate that file to Pig Latin, preserving punctuation, spacing and capatolization.
Punctuation only occurs as the last letter in a string. You should not translate any word with punctuation (other than ' and - ) with non alphabet characters in any place other than the last letter, and then only if it is punctuation. For this program punctuation is the set {,, ., !, ?, :, ;} So, for example, "Forward, need not be translated (it begins with a "), but Storm'd becomes Orm'd-stay
If the input to your program is
Plunging in the battery smoke, Right through the line they broke; Cossak and Russian Reeled from the sabre-stroke Shattered and sundered. Then they rode back, but not-- Not the six hundredyour program should print
Unging-play in-ay e-thay attery-bay oke-smay, Ight-ray ough-thray e-thay ine-lay ey-thay oke-bray; Ossack-cay and-ay Ussian-ray Eeled-ray om-fray e-thay abre-stroke-say Attered-shay and-ay undered-say. En-thay ey-thay ode-ray ack-bay, ut-bay ot--nay Ot-nay e-thay ix-say undred-hay
Your program should use good programming style including liberal use of functions. (In my program I had 8 functions). You should use self documenting code as well as frequent comments.
You must use indentation to mark blocks, and should have a consistent style for naming variables, constants, and functions. You should not have magic numbers in your program (use constants) other than 0 and 1.
You probably should use the function library that includes isalpha (man isalpha) as well as the functions tolower (man tolower) and toupper.
I also used the substr and length string functions, as well as the fact that x[n] returns the n+1 character if x is a string when n<x.length()
When you have finished with this code, email the .C (or .cpp) file to dbennett@edinboro.edu as an attachment. Make the subject of the message 131 homework 1.