I need a program that takes a string as input and then outputs the corresponding
ID: 3691180 • Letter: I
Question
I need a program that takes a string as input and then outputs the corresponding words in the International Civil Aviation Organization (ICAO) alphabet; Alpha, Bravo, Charlie, etc..
- Use an array of strings to hold the words of the alphabet
- Index the array by the positions of the letters of the alphabet. Use the letter’s integer value.
- Use array of strings to hold the words of the alphabet, and index the array by the postions of the letters of the alphabet. By using the an index with semantic content, you can avoid the need for switch statement.
- Do not use a switch statement
- Stop program from trying to index into the array using non-alphabetic characters.
Example for what the should look like.
enter string: program
output in ICAO: Papa Romeo Oscar Golf Romeo Alpha Mike
Make sure to use an array for the ICAO alphabet
The ICAO apphabet is in the image below
Explanation / Answer
Can help you with this Any queries please comment
#include <iostream>
#include <string>
using namespace std;
void printCode(int c);
int main()
{
string s;
int sz=0;
cout<<"Please enter a word to get its ICAO code: ";
cin>>s;
sz= s.size();
cout<<" Corresponding International Civil Aviation Organization (ICAO) alphabet words are) ";
int i=0;
while(i<sz)
{
char ch = s;
ch = toupper(ch);
printCode((int)ch);
cout<<" ";
i++;
}
cout<<" ";
system("pause");
return 0;
}
void printCode(int c)
{
if(c=='A')
cout<<"Alpha";
if(c=='B')
cout<<"Bravo";
if(c=='C')
cout<<"Charlie";
if(c=='D')
cout<<"Delta";
if(c=='E')
cout<<"Echo";
if(c=='F')
cout<<"Foxtrot";
if(c=='G')
cout<<"Golf";
if(c=='H')
cout<<"Hotel";
if(c=='I')
cout<<"India";
if(c=='J')
cout<<"Juliet";
if(c=='K')
cout<<"Kilo";
if(c=='L')
cout<<"Lima";
if(c=='M')
cout<<"Mike";
if(c=='N')
cout<<"November";
if(c=='O')
cout<<"Oscar";
if(c=='P')
cout<<"Papa";
if(c=='Q')
cout<<"Quebec";
if(c=='R')
cout<<"Romeo";
if(c=='S')
cout<<"Sierra";
if(c=='T')
cout<<"Tango";
if(c=='U')
cout<<"Uniform";
if(c=='V')
cout<<"Victor";
if(c=='W')
cout<<"Whiskey";
if(c=='X')
cout<<"Alpha";
if(c=='Y')
cout<<"Yankee";
if(c=='Z')
cout<<"Zulu";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.