Pig Latin Help

closed account (49ECpfjN)
I am having trouble with this Pig Latin code. I want each word to be in Pig Latin, but I also want in one line. Can someone please help me with this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include <iostream>
#include <string>

using namespace std;

bool isVowel(char ch);
string rotate(string pStr);
string pigLatinString(string pStr);

int main () {

	 while (true) {
		 string str;
          cout << "Enter a string: ";
          cin >> str;
          if (!cin) {
            break;
          }
          cout<<endl;
          //if there is a question mark in the string or what?
          //then break out of the loop

          cout << "The pig Latin form of " 
               << str << " is: "<< pigLatinString(str) << endl;
        }

}

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 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]))
	
		pStr=pStr+"-way";
	
	else 
	{//didn't start with a vowel
		
		pStr = pStr + "-";
		pStr=rotate(pStr);
		len=pStr.length();
		foundVowel=false;
	
	for (counter = 1; counter<len-1; counter++)
	
	if (isVowel(pStr[0]))
		
		{
			foundVowel=true;
			break;
		}

	else
		
			pStr=rotate(pStr);
	
	if (!foundVowel)
	
		pStr=pStr.substr(1,len)+"-way";
	
	else

		pStr = pStr + "ay";
	}
	return pStr;
}
Topic archived. No new replies allowed.