Created
April 4, 2012 18:51
-
-
Save anonymous/2304708 to your computer and use it in GitHub Desktop.
Take word, decide if first letter is capitalized, a vowel, and if the word has any vowels.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <ctime> | |
#include <ctype.h> | |
using namespace std; | |
const int wordSIZE = 50; | |
void checkVowel(char word[], int size, bool &first_VOWEL, bool &first_CAP, bool &VOWEL ); | |
int arrayLength(char[]); | |
void shiftLetters(char [], int); | |
void intro(); | |
int main() | |
{ | |
char init_word[wordSIZE]; | |
char platin[4]={'w','a','y','\0'}; | |
int count = 0, size; | |
bool first_VOWEL = NULL, first_CAP = NULL, VOWEL = NULL; | |
intro(); | |
cout << "what is your word?...\n"; | |
cin >> init_word; | |
size = arrayLength(init_word); | |
checkVowel(init_word, size, first_VOWEL, first_CAP, VOWEL); | |
cout << init_word << " " << size << endl; | |
if ( first_VOWEL == true ) { cout << "The first letter is a vowel!" << endl; } | |
else { cout << "First letter is not a vowel!" << endl; } | |
if ( first_CAP == true ) { cout << "The first letter is capital!" << endl; } | |
else { cout << "First letter is not capitalized!" << endl; } | |
if ( VOWEL == true ) { cout << "There are vowels in here!" << endl; } | |
else { cout << "There are no vowels. WTF." << endl; } | |
system("pause"); | |
return 0; | |
} | |
void intro() | |
{ | |
cout << "========PIG=LATIN=TRANSLATOR========\n" | |
<< "Translates any word into the ancient language of pig latin\n"; | |
} | |
void checkVowel(char word[], int size, bool &first_VOWEL, bool &first_CAP, bool &VOWEL ) | |
{ | |
VOWEL = false; | |
for ( int i = 0; i < size; i++ ) | |
{ | |
cout << word[0]; | |
switch( word[i] ) | |
{ | |
case 'a': | |
case 'e': | |
case 'i': | |
case 'o': | |
case 'u': | |
case 'y': | |
VOWEL = true; | |
if ( i == 0 ) { first_CAP = false; first_VOWEL = true; } | |
break; | |
case 'A': | |
case 'E': | |
case 'I': | |
case 'O': | |
case 'U': | |
case 'Y': | |
VOWEL = true; | |
if ( i == 0 ) { first_CAP = true; first_VOWEL = true; } | |
break; | |
default: | |
if ( isupper (word[0])) | |
first_CAP = true; | |
else | |
first_CAP = false; | |
first_VOWEL = false; | |
break; | |
} | |
} | |
} | |
int arrayLength(char word[]) | |
{ | |
int size=0, index=0; | |
while (word[index]!='\0') | |
{ | |
size++; | |
index++; | |
} | |
return size; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment