Help with C++ on ICOA program

 
0
 

Would appreciate any help on the attached code to get it to function properly. Think I am having a brain fart or the brain is completely fried at this point. Thanks!

The program is to take an input string and outputs the series of International Civil Aviation Organization Alphabet(ICAO) words that would be used to spell it out.

Example: Enter string: program
Phonetic version is: Papa Romeo Oscar Golf Romeo Alpha Mike

Attachments ICOA.cpp (2.42 KB)
#include <iostream>
#include <string>
using namespace std;
void displayChar(char letter);

int main()
{

	//declare variables
	string instring, sub;
	char letter;    //store user input

	int len, ipos;
	 
	cout<<"\t\tInternational Civil Aviation Organization Alphabet\n";
	cout<< "    "<<endl;
	         
	//Prompt
	cout<<"\tPlease enter a letter, (A thru Z), that you would like to convert"<< endl;
	cout<<"\tto an International Civil Aviation Organization alphabet word"<< endl;
	cout<<"\tand press enter.\t"<<endl;
	cout<<"\n\n\t";
	 

	     
	cin>>instring;
	cout<<"Phonetic version is:";
	len=instring.length();


	ipos=0;
	while(ipos<=len-1)
	{
		sub=instring.substr(ipos, 1);
		letter = sub[0];
		if(isalpha(letter)==0)
			cout<<"Will skip character"<<letter<<endl;
		else
			displayChar(letter);
		ipos=ipos+1;

	}

	         switch (letter)
{
			case 'A': case 'a': cout << "Alpha";                              
					break;
			case 'B': case 'b': cout << "Bravo";
					break;
			case 'C': case 'c': cout << "Charlie";
					break;
			case 'D': case 'd': cout << "Delta";
					break;
			case 'E': case 'e': cout << "Echo";
					break;
			case 'F': case 'f': cout << "Foxtrot";
					break;
			case 'G': case 'g': cout << "Golf";
					break;
			case 'H': case 'h': cout << "Hotel";
					break;
			case 'I': case 'i': cout << "India"; 
					break;
			case 'J': case 'j': cout << "Juliet";
					break;
			case 'K': case 'k': cout << "Kilo";
					break;
			case 'L': case 'l': cout << "Lima";
					break;
			case 'M': case 'm': cout << "Mike";
					break;
			case 'N': case 'n': cout << "November";
					break;
			case 'O': case 'o': cout << "Oscar";
					break;
			case 'P': case 'p': cout << "Papa";
					break;
			case 'Q': case 'q': cout << "Quebec";
					break;
			case 'R': case 'r': cout << "Romeo";
					break;
			case 'S': case 's': cout << "Sierra";
					break;
			case 'T': case 't': cout << "Tango";
					break;
			case 'U': case 'u': cout << "Uniform";
					break;
			case 'V': case 'v': cout << "Victor";
					break;
			case 'W': case 'w': cout << "Whiskey";
					break;
			case 'X': case 'x': cout << "X-Ray";
					break;
			case 'Y': case 'y': cout << "Yankee";
					break;
			case 'Z': case 'z': cout << "Zulu";
					break;
			default : cout << "You entered an invalid letter";
	 
	}	
		cout<<endl<<endl;

		cin.get() ;
		cin.get() ;

return 0;
}
 
0
 

Would appreciate any help on the attached code to get it to function properly. Think I am having a brain fart or the brain is completely fried at this point. Thanks!

The program is to take an input string and outputs the series of International Civil Aviation Organization Alphabet(ICAO) words that would be used to spell it out.

Example: Enter string: program
Phonetic version is: Papa Romeo Oscar Golf Romeo Alpha Mike

Already found answer to problem

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: