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
|
#include <iostream>
#include <string>
using namespace std;
int main ()
{
// declare variables
string inputString;
string outputString=" ";
char inChar;
//enter a string prompt
cout << "Enter string: ";
cin >> inputString;
//designation of length of string and beginning of loop
for (int i = 0; i < inputString.length (); i++)
{
// recalling input string
inChar = inputString.at (i);
int length = outputString.length();
//get corresponding icao word to char, allowing strings
switch (inChar)
{
case 'A': case 'a':
outputString.insert(length, " Alpha");
break;
case 'B': case 'b':
outputString.insert(length, " Bravo");
break;
case 'C': case 'c':
outputString.insert(length, " Charlie");
break;
case 'D': case 'd':
outputString.insert(length, " Delta");
break;
case 'E': case 'e':
outputString.insert(length, " Echo");
break;
case 'F': case 'f':
outputString.insert(length, " Foxtrot");
break;
case 'G': case 'g':
outputString.insert(length, " Golf");
break;
case 'H': case 'h':
outputString.insert(length, " Hotel");
break;
case 'I': case 'i':
outputString.insert(length, " India");
break;
case 'J': case 'j':
outputString.insert(length, " Juliet");
break;
case 'K': case 'k':
outputString.insert(length, " Kilo");
break;
case 'L': case 'l':
outputString.insert(length, " Lima");
break;
case 'M': case 'm':
outputString.insert(length, " Mike");
break;
case 'N': case 'n':
outputString.insert(length, " November");
break;
case 'O': case 'o':
outputString.insert(length, " Oscar");
break;
case 'P': case 'p':
outputString.insert(length, " Papa");
break;
case 'Q': case 'q':
outputString.insert(length, " Quebec");
break;
case 'R': case 'r' :
outputString.insert(length, " Romeo");
break;
case 'S': case 's' :
outputString.insert(length, " Sierra");
break;
case 'T': case 't' :
outputString.insert(length, " Tango");
break;
case 'U': case 'u' :
outputString.insert(length, " Uniform");
break;
case 'V': case 'v' :
outputString.insert(length, " Victor");
break;
case 'W': case 'w' :
outputString.insert(length, " Whiskey");
break;
case 'X': case 'x' :
outputString.insert(length, " X-ray");
break;
case 'Y': case 'y' :
outputString.insert(length, " Yankee");
break;
case 'Z': case 'z':
outputString.insert(length, " Zulu");
break;
}
}
cout << "The phonetic version is:" << outputString << endl;
system ("pause");
return 0;
}
|