Hello, when I try to run my code it gives me an error on line 28. I am having a difficult time figuring out what I am doing wrong. It might be super obvious but i've been staring at it for a while and can't figure it out. Any hints?
Here's the assignment:
Write a program that asks the user to enter a single word and outputs the series of ICAO words that would be used to spell it out. The corresponding International Civil Aviation Organization alphabet or ICAO words are the words that pilots use when they need to spell something out over a noisy radio channel.
See sample screen output for an example:
Enter a word: program
Phonetic version is: Papa Romeo Oscar Golf Romeo Alpha Mike
The specific requirement is that you write the program so that it determines the word corresponding to a specified letter using a Switch statement instead of an If structure.
As a point of reference, the ICAO alphabet is included below:
A Alpha N November
B Bravo O Oscar
C Charlie P Papa
D Delta Q Quebec
E Echo R Romeo
F Foxtrot S Sierra
G Golf T Tango
H Hotel U Uniform
I India V Victor
J Juliet W Whiskey
K Kilo X X-Ray
L Lima Y Yankee
M Mike Z Zulu
[code
#include <iostream>
#include <string>
using namespace std;
int main()
{
// Declare the variables you will use
string Word_Input;
string Word_Output = " ";
char Letters;
// Ask the user to enter a word.
cout<< " Enter a word: ";
cin>> Word_Input;
for(int i = 0; i < Word_Input.length(); i++)
{
// characters must be processed one at a time
Letters = Word_Input.at (i);
// Program will retrieve the appropriate ICAO word to match the character
switch(Letters)
case 'A': case 'a':
Word_Output += "Alpha";
break;
case 'B ': case 'a':
Word_Output += " Bravo";
break;
case 'C': case 'c':
Word_Output += " Charlie";
break;
case 'D': case 'd':
Word_Output += "Delta";
break;
case 'E': case 'e':
Word_Output += "Echo";
break;
case 'F': case 'f':
Word_Output += "Foxtrot";
break;
case 'G': case 'g':
Word_Output += " Golf";
break;
case 'H': case 'g':
Word_Output += " Hotel";
break;
case'I': case 'i':
Word_Ouput += " India ";
break;
case 'J': case 'j':
Word_Output += " Juliet";
break;
case 'K': case 'k':
Word_Output += ' Kilo';
break;
case 'L': case 'l':
Word_Output += "Lima";
break;
case 'M': case 'm':
Word_Output += "Mike";
break;
case 'N': case 'n':
Word_Output += " November";
break;
case 'O': case 'o':
Word_Output += " Oscar";
break;
case'P': case 'p':
Word_Ouput += " Papa ";
break;
case 'Q': case 'q':
Word_Output += " Quebec";
break;
case 'R': case 'r':
Word_Output += ' Romeo';
break;
case 'S': case 's':
Word_Output += "Sierra";
break;
case 'T': case 't':
Word_Output += " Tango";
break;
case 'U': case 'u':
Word_Output += " Uniform";
break;
case 'W': case 'w':
Word_Output += " Whiskey";
break;
case'X': case 'x':
Word_Ouput += " X-ray ";
break;
case 'Y': case 'y':
Word_Output += " Yankee";
break;
case 'Z': case 'z':
Word_Output += ' Zulu';
break;
}
}
// Display ICAO words
cout << " Phonetic version is: " << Word_Output << endl;