Hey all, I'm trying to write a program to convert regular words into pig latin. to do that there's three rules: if the word starts with a vowel add way to the end, ex. apple=appleway. if the word has a vowel but doesn't start with it then take the consenants it front of the first vowel and put the to the end of the word and add ay to the end. ex: balll=allbay, strong=ongstray. and if the word has no vowels just add ay to the end. ex. pfft=pfftay. i have the basis of the program done but i can't figure out how to get the computer to recognize what's a vowel and what's not. here's what i got so far, you type in the input btw:
#include<iostream.h>
#include "apstring.h"
int main()
{
apstring word;
int x=0;
cin>>word;
switch(word[x])
{
case'a':case'e':case'i':case'o':case'u':case'y':
{
x=1;
break;
}
}
if(x=1)
word=word.substr(x,word.length()-x)+word.substr(0,x)+("ay");
else
word=word+"ay";
cout<<word<<endl;
return 0;
}
for every word it just takes the first letter off, adds it to the end and then adds ay. i know that it's because x=1 that makes it just take off the first letter and add ay, but i don't know what else i should do to try and get it to work and recognize vowels. any suggestions on what to do? thanks!
#include<iostream.h>
#include "apstring.h"
int main()
{
apstring word;
int x=0;
cin>>word;
switch(word[x])
{
case'a':case'e':case'i':case'o':case'u':case'y':
{
x=1;
break;
}
}
if(x=1)
word=word.substr(x,word.length()-x)+word.substr(0,x)+("ay");
else
word=word+"ay";
cout<<word<<endl;
return 0;
}
for every word it just takes the first letter off, adds it to the end and then adds ay. i know that it's because x=1 that makes it just take off the first letter and add ay, but i don't know what else i should do to try and get it to work and recognize vowels. any suggestions on what to do? thanks!