Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Program Lab #8 Files and Strings You have been asked to construct a program that

ID: 3641990 • Letter: P

Question

Program Lab #8

Files and Strings

You have been asked to construct a program that will read a paragraph from a file, translate it from English to Pig Latin and
output the results to another file. Since you have already figured out how to translate words, this will be easy. As you will
recall, Pig Latin is a fictitious language derived from English using a few simple rules.

1.) If a word starts with a vowel (a, A, e, E, i, I, o, O, u, U) then the translation is formed by adding a "way" to the end of
word. e.g. "at" becomes "atway", "egg" becomes "eggway"

2.) If a word contains no vowels (a, A, e, E, i, I, o, O, u, U) then the translation is formed by a adding a "way" to the end of
word. e.g. "my" becomes "myway", "by" becomes "byway"

3.) If a word starts with a consonant and contains a vowel, the translation is formed by moving the consonant(s) up to the first
vowel to the end of the word and adding an "ay". e.g. "bat" becomes "atbay", "that" becomes "atthay", "three" becomes "eethray"

4.) Words that start with an initial capital letter should be translated to words with an initial capital letter.
e.g. "Houston" becomed "Oustonhay", "Iceland" becomes "Icelandway", "Marry" becomes "Arrymay"

=================================================================================================================================

Deliverables:
Write a program using good style, indents, descriptive variable names, comments, etc..
Input a paragraph in English from a file called "input.txt".
Translate the paragraph from English to Pig Latin.
Output the translation to a file called "output.txt".

NOTE: No screen output is required!

=================================================================================================================================

Hints: You are free to construct any functions you may need to perform the translation. Be sure to keep a copy of the original
text. You can use assume a paragraph will be at most 1000 characters with words no more that 30 characters long.

You will probably want functions to:
Input the paragraph from the file.
Identify words in the paragraph.
Convert the word to Pig Latin.
Output the translation to a file.
Copy all spaces and punctuation to the file as needed.

=================================================================================================================================

Example Input File:

The solution is easy, once you know how to do it. This is a test! Three, two, one...


Example Output File:

Ethay olutionsay isway easyway, onceway ouyay owknay owhay otay oday itway. Isthay isway away esttay! Eethray, otway, oneway...

Explanation / Answer

Here ya go! I hope this helps. Took a while :P Please rate LifeSaver! Just change the "input.txt" to whatever your text file is named, and also make sure it's in the SAME folder as the program. Message me if you have any questions! #include #include #include using namespace std; void wait() { cin.sync(); cin.get(); } bool startsWithVowel(string& str) { int i = 0; if(toupper(str[i]) == toupper('a') || toupper(str[i]) == toupper('e') || toupper(str[i]) == toupper('i') || toupper(str[i]) == toupper('o') || toupper(str[i]) == toupper('u') ) { int loc = 0; //Find the last letter in the string; for(size_t i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at drjack9650@gmail.com
Chat Now And Get Quote