new poster, need help with a pig latin translator. translation doesn't work properly, any tips or troubleshoots?
sorry if it seems long...
any help would be greatly appreciated
#include <iostream>
#include <string>
using namespace std;
bool isVowel(char ch);
string rotate(string pigStr);
string pigLatinString(string pigStr);
int main ()
{
char Piggy[1024];
string str;
cout << "Enter a string:";
cin.getline(Piggy, 1024);
str = Piggy;
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;
};
}//end isVowel
string rotate(string pigStr)
{
string::size_type len=pigStr.length();
string rStr;
rStr=pigStr.substr(1,len-1)+pigStr[0];
return rStr;
}
string pigLatinString(string pigStr)
{
string::size_type len;
bool foundVowel;
string::size_type counter;
if (isVowel(pigStr[0]))
pigStr=pigStr+"-way";
else
{//didn't start with a vowel
pigStr = pigStr + "-";
pigStr=rotate(pigStr);
len=pigStr.length();
foundVowel=false;
for (counter = 1; counter<len-1; counter++)
if (isVowel(pigStr[0]))
{
foundVowel=true;
break;
}
else
pigStr=rotate(pigStr);
if (!foundVowel)
pigStr=pigStr.substr(1,len)+"-way";
else
pigStr = pigStr + "ay";
}
return pigStr;
}
here is sample output
The pig Latin form ofToday is a great dayis:oday is a great day-Tay
Press any key to continue . . .