1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
|
#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);
}
}
|