Pig Latin
Mar 9, 2016 at 2:37am UTC
Hi, I need help with my pig latin code. I know there's an answer to this on here already but I don't understand it. Also, I'm not allowed to use vectors; I have to use characters and strings. Anyway, my code seems to be in an infinite loop and I don't know how to fix it.
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
#include <iostream>
#include <string>
#include <cctype>
using namespace std;
int main()
{
string vowels = "aeiou" ;
string uppervowels = "AEIOU" ;
string words;
string piggy = "" ;
string message;
string play = "N" ;
do
{
cout << "Input your phrase to be translated:" ;
getline(cin, message);
if (message[0] == vowels[0] || message[0] == vowels[1] ||
message[0] == vowels[2] || message[0] == vowels[3] ||
message[0] == vowels[4])
{
words = message + "ay" ;
piggy += words;
}
else if (message[0] == uppervowels[0] || message[0] == uppervowels[1] ||
message[0] == uppervowels[2] || message[0] == uppervowels[3] ||
message[0] == uppervowels[4])
{
words = message + "ay" ;
piggy += words;
}
else if (message[0] != vowels[0] || message[0] != vowels[1] ||
message[0] != vowels[2] || message[0] != vowels[3] ||
message[0] != vowels[4])
{
words = message[1] + message[0] + "ay" ;
piggy += words;
}
else if (message[0] != uppervowels[0] || message[0] != uppervowels[1] ||
message[0] != uppervowels[2] || message[0] != uppervowels[3] ||
message[0] != uppervowels[4])
{
words = message[1] + message[0] + "ay" ;
piggy += words
}
cout << words << endl;
cout << "Do you want to translate something? (Y or N)" ;
getline(cin, play);
}
while (play == "N" );
{
cout << "Anksthay orfay Layingpay!"
}
return 0;
}
Topic archived. No new replies allowed.