Question
Can someone add appropriate comments for this code? #include #include #include using namespace std; /** * */ bool isVowel(char ch); /** * Removes the first
Can someone add appropriate comments for this code?
#include
getline(cin, str); cout << endl; // Output the text as pig Latin 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])) pStr = pStr + "-way"; else { 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; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started