Serious help needed for a noobie!

This is the homework problem:
Use functional decomposition to make a program that inputs a letter and outputs the corresponding International Civil Aviation alphabet word. A is Alpha, B is Brave, etc, etc.


below is my code, that does not run correctly:

#include <iostream>
#include <string>
using namespace std;

int main()
{
// Declare variables

using std::string;
string letter;

// Prompt user to input

cout << "Enter letter:";
cin >> letter;

if (letter==A)
cout << "Letter is Alpha";

else if (letter==B)
cout <<"Letter is Bravo";

else if (letter==C)
cout <<"Letter is Charlie";

else if (letter==D)
cout <<"Letter is Delta";

else if (letter==E)
cout <<"Letter is Echo";

else if (letter==F)
cout <<"Letter is Foxtrot";

else if (letter==G)
cout <<"Letter is Golf";

else if (letter==H)
cout <<"Letter is Hotel";

else if (letter==I)
cout <<"Letter is India";

else if (letter==J)
cout <<"Letter is Juliet";

else if (letter==K)
cout <<"Letter is Kilo";

else if (letter==L)
cout <<"Letter is Lima";

else if (letter==M)
cout <<"Letter is Mike";

else if (letter==N)
cout <<"Letter is November";

else if (letter==O)
cout <<"Letter is Oscar";

else if (letter==P)
cout <<"Letter is Papa";

else if (letter==Q)
cout <<"Letter is Quebec";

else if (letter==R)
cout <<"Letter is Romeo";

else if (letter==S)
cout <<"Letter is Sierra";

else if (letter==T)
cout <<"Letter is Tango";

else if (letter==U)
cout <<"Letter is Uniform";

else if (letter==V)
cout <<"Letter is Victor";

else if (letter==W)
cout <<"Letter is Whiskey";

else if (letter==X)
cout <<"Letter is X-ray";

else if (letter==Y)
cout <<"Letter is Yankee";

else if (letter==Z)
cout <<"Letter is Zulu";
else
cout <<" Please enter one capitol letter from the alphabet.";
cout <<endl;

system("pause");
return(0);
}
Last edited on
Please edit your post and make sure your code is [code]between code tags[/code] so that it has line numbers and syntax highlighting, as well as proper indentation.

You need to surround single characters with single quotes: if(letter == 'A')
Last edited on
i was wondering if "else if" is wrong...
Every single one of your statements is wrong. Like @LB said

You need to surround single characters with single quotes: if(letter == 'A')


Do that to every else if statement aswell.
Last edited on
ok, This fixed it! Thank yall so much! simple corrections!
once again, many thanks!
me :)
Last edited on
Topic archived. No new replies allowed.