Computer Science

Using the attached pigLatinString.cpp as a starting point, create a Pig Latin Converter program that will read in a file called “pigLatinFile.in” of English sentences, convert them into Pig Latin, and will output them back to a file called “pigLatinFile.out”.

Rules:

1) While I may not use the same input file provided to you, you can be assured that it will contain no more than 500 words on the same line like the sample input file provided here.

2) You can name your cpp file for this assignment anything you wish, so long as you attach it with your submission and it will read in and output the exact file names above and like the sample files.

Special Requirements:

1) The comma (,) and period(.) characters will be considered special punctuation characters, and even after conversion to Pig Latin, these characters will need to still appear at the end of each word. All other characters can be left where Malik’s “rotate” function puts them in the word.

2) If the first letter of the English word is capitalized, then the first letter of the word converted into Pig Latin should also be capitalized.

An Example of these Requirements is “David,” converted into Pig Latin by your program should be “Avid-day,”

The sample program I gave can only translate one word to programming Latin, I need you to enter a lot of text instead of just one word.

// Program: Pig Latin Strings

// This program reads a string and outputs the pig latin form

// of the string.

//*************************************************************

#include <iostream>

#include <string>

using namespace std;

bool isVowel(char ch);

string rotate(string pStr);

string pigLatinString(string pStr);

int main()

{

string str;

cout << “Enter a string: “;

cin >> str;

cout << endl;

cout << “The pig Latin form of ” << str << ” is: ”

<< pigLatinString(str) << endl;

return 0;

}

bool isVowel(char ch)

{

switch (ch)

{

case ‘A’:

case ‘E’:

case ‘I’:

case ‘O’:

case ‘U’:

case ‘Y’:

case ‘a’:

case ‘e’:

case ‘i’:

case ‘o’:

case ‘u’:

case ‘y’:

return true;

default:

return false;

}

}

string rotate(string pStr)

{

string::size_type len = pStr.length();

string rStr;

rStr = pStr.substr(1, len – 1) + pStr[0];

return rStr;

}

string pigLatinString(string pStr)

{

string::size_type len;

bool foundVowel;

string::size_type counter;

if (isVowel(pStr[0])) //Step 1

pStr = pStr + “-yay”;

else //Step 2

{

pStr = pStr + ‘-‘;

pStr = rotate(pStr); //Step 3

len = pStr.length(); //Step 3.a

foundVowel = false; //Step 3.b

for (counter = 1; counter < len – 1;

counter++) //Step 3.d

if (isVowel(pStr[0]))

{

foundVowel = true;

break;

}

else //Step 3.c

pStr = rotate(pStr);

if (!foundVowel) //Step 4

pStr = pStr.substr(1, len) + “-way”;

else

pStr = pStr + “ay”;

}

return pStr; //Step 5

}

Example:

Input:

Harry Potter is a series of fantasy novels written by British author J. K. Rowling. The novels chronicle the life of a young wizard, Harry Potter, and his friends Hermione Granger and Ron Weasley, all of whom are students at Hogwarts School of Witchcraft and Wizardry. The main story arc concerns Harry’s struggle against Lord Voldemort, a dark wizard who intends to become immortal, overthrow the wizard governing body known as the Ministry of Magic, and subjugate all wizards and non-magical people.

Output:

Arry-hay Otter-pay is-yay a-yay eries-say of-yay antasy-fay ovels-nay itten-wray y-bay Itish-bray author-yay J-way. K-way. Owling-ray. E-thay ovels-nay onicle-chray e-thay ife-lay of-yay a-yay young-yay izard-way, Arry-hay Otter-pay, and-yay is-hay iends-fray Ermione-hay Anger-gray and-yay On-ray Easley-way, all-yay of-yay om-whay are-yay udents-stay at-yay Ogwarts-hay Ool-schay of-yay Itchcraft-way and-yay Izardry-way. E-thay ain-may ory-stay arc-yay oncerns-cay Arry’s-hay uggle-stray against-yay Ord-lay Oldemort-vay, a-yay ark-day izard-way o-whay intends-yay o-tay ecome-bay immortal-yay, overthrow-yay e-thay izard-way overning-gay ody-bay own-knay as-yay e-thay Inistry-may of-yay Agic-may, and-yay ubjugate-say all-yay izards-way and-yay on-magical-nay eople-pay.

Order now and get 10% discount on all orders above $50 now!!The professional are ready and willing handle your assignment.

ORDER NOW »»