Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the attached pigLatinString.cpp(pasted below) as a starting point, create a Pig Latin Converter program that will read in a file called pigLatinFile.in of English

Using the attached pigLatinString.cpp(pasted below) 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,"

// Program: Pig Latin Strings

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

// of the string.

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

#include

#include

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

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Case Studies In Business Data Bases

Authors: James Bradley

1st Edition

0030141346, 978-0030141348

More Books

Students also viewed these Databases questions

Question

Identify three types of physicians and their roles in health care.

Answered: 1 week ago

Question

Compare the types of managed care organizations (MCOs).

Answered: 1 week ago