The Question is:
Write a program that asks a user to enter one of the following state abbreviations: NC, SC, GA, FL, or AL. The program should then display the name of the state that cooresponds with the abbreviation entered ( North Carolina, South Carolina, Georgia, Florida, or Alabama).
Input Validation: Accept abbreviations with both letters in uppercase or both in lowercase. Display an error message if an abbreviation other than what is listed is entered.
So far this is what I got.
#include <iostream>
#include <string>
using namespace std;
int main()
{
string sa; //State Abbreviation
string NC = "North Carolina";
string SC = "South Caronlina";
string GA = "Georgia";
string FL = "Florida";
string AL = "Alabama";
cout << "Enter one of the following State Abbreviations for full name:" << endl;
cout << "NC, SC, GA, FL, or AL. ";
cin >> sa;
if (sa == NC)
NC = "North carolina";
else if (sa == SC)
SC = "South Carolina";
cout << "The State Abbreviation you entered stands for " << sa << endl;
return 0;
}
I have tried several methods and it either gives me no output after I enter in the NC or SC or I get an error about bool if I use the following: if (sa == NC) || (sa == nc)
I have not finished entering the rest of my problem/answer because its not functioning the way I need it to.
I did get it to display "The State Abbreviation you entered stands for NC, or SC" Depending on which of the 2 I entered. Thanks in advanced!!