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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
#include <stdio.h>
void printInfo () ;
void printMenu () ;
int validInput () ;
int returnString (char *string) ;
int menuChoice () ;
void clearScreen ();
char restartDo ();
void pigLatin ( char userString [] , int max ) ;
void constantsVowels ( char userStr [] , int maxLetter ) ;
int main ()
{
int userChoice , number;
char userWord [ 21 ] , decision , enterWord ;
printInfo () ;
do{
returnString(userWord);
printMenu () ;
userChoice = menuChoice ();
if(userChoice == 1)
pigLatin( userWord, number );
else if(userChoice == 2)
constantsVowels ( userWord , number);
else if(userChoice == 3)
return 0;
decision = restartDo ();
}
while(decision == 'y' || decision == 'Y');
}
void printInfo ()
{
printf ( "Welcome To The String Manipulator\n" ) ;
printf ( "This Program Will Take Any Word You Enter And Either\n" ) ;
printf ( "~ Convert It To Pig Latin\n" ) ;
printf ( "~ Count Vowels And Consonants\n" ) ;
printf ( "_________________________________\n" ) ;
printf ( "Please Enter A Word (No Spaces, Max Of 20 Characters)\n" ) ;
}
void printMenu()
{
printf ( " [ Options ]\n" ) ;
printf ( "1) Pig - Latin\n" ) ;
printf ( "2) Count Vowels and Consonants\n" ) ;
printf ( "3) Exit\n" ) ;
printf ( "________________________________________\n" ) ;
printf ( "Please Enter Your Choice < 1 - 3 >\n" ) ;
}
int returnString(char *string)
{
scanf("%s", &*string);
getchar();
}
int validInput ( )
{
}
int menuChoice ()
{
int menu;
scanf ( "%i" , &menu ) ;
getchar () ;
return menu;
}
void pigLatin ( char userString [] , int max )
{
char beggining , end ;
int count ;
max = max - 1 ;
userString [ max+1 ] = userString [ 0 ] ;
for ( count = 1 ; count <= max + 1 ; count ++ )
{
printf ( "%c%" , userString [ count ] ) ;
}
printf ( "ay" ) ;
printf ( "\n" ) ;
}
void constantsVowels ( char userStr [0] , int maxLetter )
{
int count , count2 , count3 , vCount = 0 , cCount ;
int vowel ;
char vowelAllowed [ 13 ] = { 'a' , 'A' , 'e' , 'E' , 'i' , 'I' , 'o' , 'O' , 'u' , 'U' , 'y' , 'Y' } ;
char constantAllowed [ 41 ] = { 'b' , 'B' , 'c' , 'C' , 'd' , 'D' , 'f' , 'F' , 'g' , 'G' , 'h' , 'H' , 'j' , 'J' , 'k' , 'K' , 'l' , 'L' , 'm' , 'M' , 'n' , 'N' , 'p' , 'P' , 'q' , 'Q' , 'r' , 'R' , 's' , 'S' , 't' , 'T' , 'v' , 'V' , 'w' , 'W' , 'x' , 'X' , 'z' , 'Z' } ;
for ( count = 0 ; count < maxLetter ; count ++ )
{
for ( count2 = 0 ; count2 < 12 ; count2 ++ )
{
if ( userStr [ count ] == vowelAllowed [ count2 ] )
vCount ++ ;
}
for ( count3 = 0 ; count3 < 42 ; count3 ++ )
{
if ( userStr [ count ] == constantAllowed [ count3 ] )
{
cCount ++ ;
}
}
}
printf ( "Your Word Has:\n" ) ;
printf ( "%i" , vCount ) ; printf ( " Vowels\n" ) ;
printf ( "%i" , cCount ) ; printf ( " Consonants\n" ) ;
}
void clearScreen ()
{
printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
}
char restartDo ()
{
char yesNo;
printf("Would You Like To Manipulate Another Word ?\n");
scanf("%c", &yesNo);
getchar();
return yesNo;
}
|