Skip to content

Instantly share code, notes, and snippets.

@ebba0194
Created December 11, 2017 20:06
Show Gist options
  • Save ebba0194/91e4235dbb5b4be479fd01cd8671b2be to your computer and use it in GitHub Desktop.
Save ebba0194/91e4235dbb5b4be479fd01cd8671b2be to your computer and use it in GitHub Desktop.
#include <iostream>
#include <string>
using namespace std;
string province(string);
int main(){
string city, abbrev, prov;
cout<<"Enter city: ";
getline(cin,city);
cout<<"Enter province abbreviation: ";
cin>>abbrev;
prov = province(abbrev);
cout<<city+prov;
return (0);
}
string province (string abbrev){
struct provNames{
string abr;
string full;
}AB, NB, NT, PQ, BC, NF, ON, SK, MB, NS, PE, YK;
AB.abr="AB";
AB.full=", Alberta";
NB.abr="NB";
NB.full=", New Brunswick";
NT.abr="NT";
NT.full=", Northwest Territories";
PQ.abr="PQ";
PQ.full=", Quebec";
BC.abr="BC";
BC.full=", British Columbia";
NF.abr="NF";
NF.full=", Newfoundland";
ON.abr="ON";
ON.full=", Ontario";
SK.abr="SK";
SK.full=", Saskatchewan";
MB.abr="MB";
MB.full=", Manitoba";
NS.abr="NS";
NS.full=", Nova Scotia";
PE.abr="PE";
PE.full=", Prince Edward Island";
YK.abr="YK";
YK.full=", Yukon";
if (abbrev == AB.abr){
return (AB.full);
}
else if (abbrev == NB.abr){
return (NB.full);
}
else if (abbrev == NT.abr){
return (NT.full);
}
else if (abbrev == PQ.abr){
return (PQ.full);
}
else if (abbrev == BC.abr){
return (BC.full);
}
else if (abbrev == NF.abr){
return (NF.full);
}
else if (abbrev == ON.abr){
return (ON.full);
}
else if (abbrev == SK.abr){
return (SK.full);
}
else if (abbrev == MB.abr){
return (MB.full);
}
else if (abbrev == NS.abr){
return (NS.full);
}
else if (abbrev == PE.abr){
return (PE.full);
}
else if (abbrev == YK.abr){
return (YK.full);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment