Program 8

Home Windows C++ 241 C++ 242 Contact Info Contents

Program 8 - March 4

Up

String and File Processing Assignment

You can think of this assignment as Pig Latin 201.

Your program should read a text file containing English prose, in paragraphs separated by blank lines. There is no special marker for the end of the file, you will have to detect that yourself. Output is a text file containing pig latin. The rules to use for this version of pig latin are a bit more complicated than the earlier assignment:

  1. Separate out all words by detecting white space and punctuation. Put the punctuation back in the proper place in your translation. 

  2. If a word begins with a vowel (a, e, i, o, u) add "way" to the end of the word.

  3. If a word begins with a consonant, move that consonant plus any following consonants to the end of the word and add "ay".

  4. Treat "y" as a consonant at the start of a word, but as a vowel everywhere else.

  5. If a word was capitalized, it should end up capitalized correctly.

Example - the  second paragraph above in Pig Latin:

Ouryay ogrampray ouldshay eadray away extay ilefay ontainingcay Englishway osepray, inway aragraphsway eparatedsay ybay ankblay ineslay. Erethay isway  onay ecialspay arkermay orfay ethay endway of way ethay ilefay, ouyay illway avehay otay etectday atthay ourselfyay. Outputway isway away extay ilefay ontainingcay igpay atinlay. Ethey ulesray otay useway orfay isthay ersionvay ofway igpay atinlay areway away itbay oremay omplicatedcay anthay ethay earlierway assignmentway:

Requirements

Your program should use the following features of C++ which we have just studied:

  1. Input from and output to a file.

  2. The string class for holding an input paragraph, an output paragraph and the word you are working on.

  3. Exceptions to catch memory allocation and file I/O errors.

You may choose to write this program either with or without user-defined data types.

Up

Home Windows C++ 241 C++ 242 Contact Info Contents

Copyright © 2000  Charlie Poole. All rights reserved.
Revised: July 15, 2002 - cpoole@ctc.edu