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

I need help with this assignment It?s C++, pig latin translation. Translate each

ID: 3762191 • Letter: I

Question

I need help with this assignment

It?s C++, pig latin translation. Translate each word in each sentence into Pig Latin and print out the translated phrase. Ifa word starts with a vowel, just add ?yay? to the end. If not, remove the first ?syllable? (all of the initial consonants) from the word and place it at the end of the word, and add the suffix ?ay?. must be able to handle words without any vowels by adding ?ay? to the end, and must be able to handle words contain all vowels. Must be able to handle punctuation. ! ? example: input: Aeiou; aeiou. Hmm, ''Aeiou'' and ''aeiou''.. Are strange, so is ''a'' and ''b''. ''Art'', ''A'' and ''B'' are interesting too. output: Oremay omplexcay: Aeiouyay; aeiouyay. Hmmay, ''Aeiouyay'' andyay ''aeiouyay''... Areyay angestray, osay isyay ''ayay'' andyay ''bay''. ''Array'', ''Ayay'' andyay ''Bay'' areyay interestingyay ootay. Please comment and explain your codes

Explanation / Answer

#include<iostream>
#include <iomanip>
#include<string>
using namespace std;
bool errorCheck(string);
void firstLetter(string);
void wordTranslate(string);
int main()
{
string wordInput="";
bool inputError = false;
char runSentinel = 'y';
cout << "          
cout << "          
cout << "          
//cin.get();
cout << "Welcome to the Pig Latin Translator. " << endl;
cout << "Would you like to translate a word? (y/n)";
cin >> runSentinel;
do
{
if (runSentinel == 'y')
{
cout << "Please enter the word you would like to be translated, " << endl;
cout << "and please use only lower case letters. " << endl;
cin >> wordInput;
inputError = errorCheck(wordInput);
}
if (inputError == false)
{
firstLetter(wordInput);
//();
}
cin.ignore();
cout << "Would you like to translate a word? (y/n)";
cin >> runSentinel;
}
while (runSentinel != 'n');
return 0;
}
bool errorCheck(string wordInput)
{
bool errorVerif = false;
int Length = wordInput.length();
int Counter = 0;
char *specificLetter = &wordInput.at(0);
while (Counter < Length && errorVerif == false)
{
if (!isalpha(*specificLetter))
{
cout << *specificLetter << "is not an acceptable entry. Please re-enter your word.";
errorVerif = true;
}
if (isspace(*specificLetter))
{
cout << *specificLetter << "is not an acceptable entry. Please re-enter your word.";
errorVerif = true;
}
cout << "*specificLetter:" << *specificLetter << endl;
*specificLetter++;
Counter++;
}
return errorVerif;
}
void firstLetter(string wordInput)
{
char firstLetter;
firstLetter = wordInput.at(0);
if (firstLetter == 'a' || firstLetter == 'e' || firstLetter == 'i' || firstLetter == 'o' || firstLetter == 'u')
{
cout << "In Pig Latin, that would be " << wordInput << "way" << endl;
}
else
{
wordTranslate(wordInput);
}
}
void wordTranslate(string wordInput)
{
char firstLetter;
char lastLetter = wordInput.length();
firstLetter = wordInput.at(0);
string otherLetters = wordInput.substr((1), (lastLetter - 1));
cout << "In Pig Latin, that would be " << otherLetters << firstLetter << "ay." << endl;
}