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
|
#include <iostream>
#include <iomanip>
#include <string>
#include <cctype>
using namespace std;
int main()
{ //Aray decloration of ICAO words stored between Index[0] - Index[26]
string wordICAO[26] = {"Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November",
"Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"};
string instring; //string input
string outstring; //string output
char letter ; //character of string
int index = 0; //loop control and index variable
int len; //integer of length and position of first character
cout<< "Enter a word for ICAO spelling" << endl; //prompt user for input of word
getline(cin, instring); //read data string
len = instring.length() ; //len = number of char in string
cout << endl << "Phonetic version is: " << setw(6);
while (instring !="Quit"|| instring != "quit" || instring !="QUIT")
{
for(int index = 0;index < instring.length();index ++) //for loop index is less than or equal to string length
{
letter = instring[index]; //converts string into individual char
letter = toupper(letter); //char is converted to uppercase
if(isalpha(letter) == 0) //will skip none letter characters
{
cout << endl << "will skip letter : " << letter << endl;
}
else
outstring = wordICAO[letter-'A']; //subtracts 'A' from uppercase letter to get words postion
cout << outstring << " "; //prints out string of ICAO words
}
cout << endl << endl << "Enter a word for ICAO spelling" << endl; //prompt user for input of word
cout << "Enter \"Quit\" to Exit program" << endl<< endl;
getline(cin, instring); //read data string
while (instring =="Quit" || instring == "quit" || instring =="QUIT" )
{
cout << "Goodby" << endl;
cout << endl;
system("pause");
return 0;
}
len = instring.length() ;
cout << endl << "Phonetic version is: " << setw(6);
}
}
|