14 Replies - 1294 Views - Last Post: 13 June 2008 - 04:12 PM Rate Topic: -----

#1 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Help with errors in void / switch statement

Posted 12 June 2008 - 07:40 PM

The program is to input a string and output the corresponding words in the International Civil Aviation Organization (ICAO) phonetic alphabet using a switch statement. When I compile mine I get errors in the void function 2 on each of three lines. I put the errors in the code below about the line. I have no idea what I'm doing wrong. I have search on everything I can think of on google and have gotten this far, but don't know where to go from here. Any help would be greatly appreciated.



#include <iomanip>
#include <string>
#include <iostream>
#include <cctype>

using namespace std;

void  GetString( int, char);

int main()
{
	//declare variables
	  
	string myString;			  // Word to convert to ICAO
	char letter;				  // Current input character
	int stringLen;				// Length of string
	
  
   // Instructions for user input
   cout << "Please enter a word to convert" << endl;
   getline(cin,myString);					 // user input   
   stringLen = myString.size();			   //how long is the string		  
 
   cout << "Phonetic version is: " << endl;  
		 
   for(int i=0; i<stringLen; i++)
   {		  
			  letter = myString[i];  
			GetString(stringLen, letter);
			 
		}
		 cin.get();  
		 
	 return 0;
}
void	GetString (int stringLen, char letter )

	(error - expected init-declarator before "int" and expected `,' or `;' before "int" )			   
	int i=0; 

   (error - expected unqualified-id before "while" and expected `,' or `;' before "while" )
	  while (i<stringLen) 
			  
		switch (letter);
		{
(error - expected unqualified-id before '{' token and expected `,' or `;' before '{' token )
			  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 << "Invalid entry. Must be a letter of the alphabet.";
			
	   
}




Is This A Good Question/Topic? 0
  • +

Replies To: Help with errors in void / switch statement

#2 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 678
  • Joined: 26-May 08

Re: Help with errors in void / switch statement

Posted 12 June 2008 - 07:48 PM

void	GetString (int stringLen, char letter )



Just a wild guess.. maybe it needs a open and close brackets..

void	GetString (int stringLen, char letter ){  <<open bracket.. 

.........
........

}  <<close bracket



This post has been edited by mensahero: 12 June 2008 - 07:50 PM

Was This Post Helpful? 0
  • +
  • -

#3 no2pencil  Icon User is offline

  • Head MFIC
  • member icon

Reputation: 5066
  • View blog
  • Posts: 26,448
  • Joined: 10-May 07

Re: Help with errors in void / switch statement

Posted 12 June 2008 - 07:50 PM

As well, the fucntion should be declared the same as it's used:

void  GetString( int, char);
...
void GetString (int stringLen, char letter )



These should both be the same, & as previously stated, you are missing your open & close bracket for the function.
Was This Post Helpful? 0
  • +
  • -

#4 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 06:43 AM

View Postno2pencil, on 12 Jun, 2008 - 07:50 PM, said:

As well, the fucntion should be declared the same as it's used:

void  GetString( int, char);
...
void GetString (int stringLen, char letter )



These should both be the same, & as previously stated, you are missing your open & close bracket for the function.



View Postrckjbrewer, on 13 Jun, 2008 - 06:42 AM, said:

View Postno2pencil, on 12 Jun, 2008 - 07:50 PM, said:

As well, the fucntion should be declared the same as it's used:

void  GetString( int, char);
...
void GetString (int stringLen, char letter )



These should both be the same, & as previously stated, you are missing your open & close bracket for the function.

Was This Post Helpful? 0
  • +
  • -

#5 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 06:48 AM

View Postno2pencil, on 12 Jun, 2008 - 07:50 PM, said:

As well, the fucntion should be declared the same as it's used:

void  GetString( int, char);
...
void GetString (int stringLen, char letter )



These should both be the same, & as previously stated, you are missing your open & close bracket for the function.



As you can see I'm new at using this forum and replied twice without anything, because I didn't realize what to do. Sorry.

Thanks that cleared up the errors I was having, but now I get errors saying that everything under my switch statement is not within the switch statement. Any suggestions.

Here is my code with the changes.

// Internatonal Civil Aviation Organization Code
// Input word and output Phonetic version
// of the ICAO alphabet

#include <iomanip>
#include <string>
#include <iostream>
#include <cctype>

using namespace std;

void  GetString( int stringLen, char letter);

int main()
{
	//declare variables
	  
	string myString;			  // Word to convert to ICAO
	char letter;				  // Current input character
	int stringLen;				// Length of string
	
  
   // Instructions for user input
   cout << "Please enter a word to convert" << endl;
   getline(cin,myString);					 // user input   
   stringLen = myString.size();			   //how long is the string		  
 
   cout << "Phonetic version is: " << endl;  
		 
   for(int i=0; i<stringLen; i++)
   {		  
			  letter = myString[i];  
			GetString(stringLen, letter);
			 
		}
		 cin.get();  
		 
	 return 0;
}
void	GetString (int stringLen, char letter )
{						
	int i=0;
	
	  while (i<stringLen)
			  
		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 << "Invalid entry. Must be a letter of the alphabet.";
			}
	   
}



Was This Post Helpful? 0
  • +
  • -

#6 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 678
  • Joined: 26-May 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 07:03 AM

Quote

while (i<stringLen)


the first while.. whats its purpose? well if you want to loop statement inside that .. it must also have a open and close bracket.. everything must be under brackets.. you should have known that..

Quote

switch (letter);


see that one.. " ; " semi-colon are used for IMO.. terminate a line of code.. I don't know the right term.. correct me if im wrong..

remove that ";" .... :blink:
Was This Post Helpful? 0
  • +
  • -

#7 Trogdor  Icon User is offline

  • D.I.C Addict
  • member icon

Reputation: 15
  • View blog
  • Posts: 627
  • Joined: 06-October 06

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 07:58 AM

i guess the original idea was to let the whilestatement loop through the letters of the string.
And it does execute. if you do not put the { } brackets around a code-block it will operate on the next statement instead, which is the switch.
But indeed, since you are giving the function only one letter, why bother with a while loop at all.
As you have it there by the way, without changeing anything that will make the while stop (like increasing i) you might have made an endless loop.
Bad idea.
Was This Post Helpful? 0
  • +
  • -

#8 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 10:28 AM

View PostTrogdor, on 13 Jun, 2008 - 07:58 AM, said:

i guess the original idea was to let the whilestatement loop through the letters of the string.
And it does execute. if you do not put the { } brackets around a code-block it will operate on the next statement instead, which is the switch.
But indeed, since you are giving the function only one letter, why bother with a while loop at all.
As you have it there by the way, without changeing anything that will make the while stop (like increasing i) you might have made an endless loop.
Bad idea.




I think I see what you mean. I revised the code and did away with the while statement and made it a for statement. When I run the program and enter (for example) "hello" I get :
HotelHotelHotelHotelHotelEchoEchoEchoEchoEchoLimaLimaLimaLimaLimaLimaLimaLimaLimaLimaOscarOscarOscarOscarOscar


I think it has something to do with either my for statement or stringLen.

#include <iomanip>
#include <string>
#include <iostream>
#include <cctype>

using namespace std;

void  GetString( int stringLen, char letter);

int main()
{
	//declare variables
	  
	string myString;			  // Word to convert to ICAO
	char letter;				  // Current input character
	int stringLen;				// Length of string
	
  
   // Instructions for user input
   cout << "Please enter a word to convert" << endl;
   getline(cin,myString);					 // user input   
   stringLen = myString.size();			   //how long is the string		  

   cout << "Phonetic version is: " << endl;  
		 
   for(int i=0; i<stringLen; i++)
   {		  
			  letter = myString[i];  
			GetString(stringLen, letter);
			 
		}
		 cin.get();  
		 
	 return 0;
}
void	GetString (int stringLen, char letter )
{						
	
	  for (int i=0; i<stringLen; i++)
			  
		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 << "Invalid entry. Must be a letter of the alphabet.";
			}
	   
}



Was This Post Helpful? 0
  • +
  • -

#9 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 678
  • Joined: 26-May 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 10:38 AM

what's your purpose for putting up a loop? in your getString method?

the way I see it..

1. when getString(someLength, someLetter) method is invoke it will..

2. case 'a' ... and someLength = 5...

3. it will cout.. "ALPHA" .. 5 times..

output:

ALPHAALPHAALPHAALPHAALPHA << something like that..

well that's how your method would work.. basing from your code..

lastly IDK c++.. but couldn't this be possible..

case 'A' || 'a' : 



correct me if i'm wrong.. but shouldn't the "or" operator be used it that situation..

This post has been edited by mensahero: 13 June 2008 - 10:45 AM

Was This Post Helpful? 0
  • +
  • -

#10 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 11:16 AM

View Postmensahero, on 13 Jun, 2008 - 10:38 AM, said:

what's your purpose for putting up a loop? in your getString method?

the way I see it..

1. when getString(someLength, someLetter) method is invoke it will..

2. case 'a' ... and someLength = 5...

3. it will cout.. "ALPHA" .. 5 times..

output:

ALPHAALPHAALPHAALPHAALPHA << something like that..

well that's how your method would work.. basing from your code..

lastly IDK c++.. but couldn't this be possible..

case 'A' || 'a' : 



correct me if i'm wrong.. but shouldn't the "or" operator be used it that situation..



I'm not sure I understand what you are saying. Do you recommend I remove the void function comepletly?

I will try changing the case code to the "or" operator.
Was This Post Helpful? 0
  • +
  • -

#11 mensahero  Icon User is offline

  • I Desire...
  • member icon

Reputation: 17
  • View blog
  • Posts: 678
  • Joined: 26-May 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 11:33 AM

Quote

I'm not sure I understand what you are saying. Do you recommend I remove the void function comepletly?

I will try changing the case code to the "or" operator.


nope.. what I mean is..

for (int i=0; i<stringLen; i++)



that one.. whats its purpose on your getString method.. and about the "or" operator in switch.. its just a suggestion.. i'm not sure.. I'm not a C++ guy.. lmao.. :blink: ..

Try to read your method/codes line by line.. and visualize what will they do.. that way you'll know.. what is wrong.. :blink:
Was This Post Helpful? 0
  • +
  • -

#12 >>codingGeek<<  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 28
  • Joined: 12-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 12:53 PM

You may have already figured out your problem...but as mensahero pointed out, the for loop before your switch statement has no purpose except to cause the current letter to be repeated "strlen" times.

Since you have the for loop stepping through the string character by character and calling the function, you do not need to pass the length of the string to the method nor do you need the loop in that method. You already have the loop in your main.
Was This Post Helpful? 0
  • +
  • -

#13 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 03:43 PM

View Post>>codingGeek<<, on 13 Jun, 2008 - 12:53 PM, said:

You may have already figured out your problem...but as mensahero pointed out, the for loop before your switch statement has no purpose except to cause the current letter to be repeated "strlen" times.

Since you have the for loop stepping through the string character by character and calling the function, you do not need to pass the length of the string to the method nor do you need the loop in that method. You already have the loop in your main.



Thanks for all the help when I took the for loop out it worked perfectly.

I also tried case 'A' || 'a' :, but I got an error saying "duplicate case value previously used here".

Again thanks for everyone's help.
Was This Post Helpful? 0
  • +
  • -

#14 gabehabe  Icon User is offline

  • GabehabeSwamp
  • member icon




Reputation: 1376
  • View blog
  • Posts: 10,951
  • Joined: 06-February 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 03:59 PM

I feel like I'm a little late here, but I just cleaned up your code from your original post and it now works fine:
#include <iomanip>
#include <string>
#include <iostream>
#include <cctype>

using namespace std;

void  GetString( int, char );

int main()
{
    //declare variables

    string myString;              // Word to convert to ICAO
    char letter;                  // Current input character
    int stringLen;                // Length of string

    // Instructions for user input
    cout << "Please enter a word to convert" << endl;
    getline(cin,myString);                     // user input
    stringLen = myString.size();               //how long is the string

    cout << "Phonetic version is: " << endl;

    for(int i=0; i<stringLen; i++)
    {
        letter = myString[i];
        GetString(stringLen, myString[i]);

    }
    cin.get();

    return 0;
}


void    GetString (int stringLen, char letter)
{
    switch (letter) // shouldn't have a semi-colon here
    {
        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 << "Invalid entry. Must be a letter of the alphabet.";
    }
    cout << endl; // space the output
}

Your biggest problem was that you had a ; after your switch line, where you don't need one. Take a look, and feel free to ask any questions if I did anything that you don't understand.

Hope this helps :)
Was This Post Helpful? 0
  • +
  • -

#15 rckjbrewer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 8
  • Joined: 07-June 08

Re: Help with errors in void / switch statement

Posted 13 June 2008 - 04:12 PM

View Postgabehabe, on 13 Jun, 2008 - 03:59 PM, said:

I feel like I'm a little late here, but I just cleaned up your code from your original post and it now works fine:
#include <iomanip>
#include <string>
#include <iostream>
#include <cctype>

using namespace std;

void  GetString( int, char );

int main()
{
    //declare variables

    string myString;              // Word to convert to ICAO
    char letter;                  // Current input character
    int stringLen;                // Length of string

    // Instructions for user input
    cout << "Please enter a word to convert" << endl;
    getline(cin,myString);                     // user input
    stringLen = myString.size();               //how long is the string

    cout << "Phonetic version is: " << endl;

    for(int i=0; i<stringLen; i++)
    {
        letter = myString[i];
        GetString(stringLen, myString[i]);

    }
    cin.get();

    return 0;
}


void    GetString (int stringLen, char letter)
{
    switch (letter) // shouldn't have a semi-colon here
    {
        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 << "Invalid entry. Must be a letter of the alphabet.";
    }
    cout << endl; // space the output
}

Your biggest problem was that you had a ; after your switch line, where you don't need one. Take a look, and feel free to ask any questions if I did anything that you don't understand.

Hope this helps :)



Thanks I never compared what I originally had to the final code. I feel like I have a better understanding of what I'm doing.

Thanks,
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1