Question: #include #include #include #include functions.h using std::cout, std::cin, std::endl, std::exception, std::invalid _ argument; using std::getline, std::string; int mapping ( string loc ) { int
#include
#include
#include
#include "functions.h
using std::cout, std::cin, std::endl, std::exception, std::invalidargument;
using std::getline, std::string;
int mapping string loc
int num ;
if loc "Boston" num ;
else if loc "Hartford" num ;
else if loc "NewYork" num ;
else if loc "Philadelphia" num ;
else if loc "Baltimore" num ;
else if loc "WashingtonDC" num ;
else if loc "Pittsburgh" num ;
else if loc "Cleveland" num ;
else if loc "Detroit" num ;
else if loc "Chicago" num ;
else if loc "Indianapolis" num ;
else if loc "Nashville" num ;
else if loc "Atlanta" num ;
else if loc "Houston" num ;
else if loc "Austin" num ;
else if loc "Dallas" num ;
else if loc "Denver" num ;
else if loc "Albuquerque" num ;
else if loc "Phoenix" num ;
else if loc "Sacramento" num ;
else
try throw invalidargumentUndefined location";
catch std::invalidargument const& e cout ewhat endl;
return num;
string revmapping int num
string loc;
switch num
case : loc "Boston"; break;
case : loc "Hartford"; break;
case : loc "NewYork"; break;
case : loc "Philadelphia"; break;
case : loc "Baltimore"; break;
case : loc "WashingtonDC"; break;
case : loc "Pittsburgh"; break;
case : loc "Cleveland"; break ;
case : loc "Detroit"; break;
case : loc "Chicago"; break;
case : loc "Indianapolis"; break;
case : loc "Nashville"; break;
case : loc "Atlanta"; break;
case : loc "Houston"; break;
case : loc "Austin"; break;
case : loc "Dallas"; break;
case : loc "Denver"; break;
case : loc "Albuquerque"; break;
case : loc "Phoenix"; break;
case : loc "Sacramento"; break;
default: loc "undefined"; break;
if loc "undefined"
try throw invalidargumentUndefined location";
catch std::invalidargument const& e cout ewhat endl;
return loc;
void getopconst string& line, string operation
std::istringstream sinline;
sin operation;
if sinfail
sinclear;
sinignorestd::numericlimits::max
;
operation "ignore";
void getlocconst string& line, string location
std::istringstream sinline;
sin location;
if sinfail
sinclear;
sinignorestd::numericlimits::max
;
void printinst
cout enter operation: push insert pop clear print locations quit" endl;
cout enter location from above list on next line" endl;
cout enter an empty line to end input" endl;
cout endl;
cout WARNING: push operation pushes location in push order without any location ordering" endl;
cout endl;
void printinst
cout Locations: Boston Hartford NewYork Philadelphia Baltimore WashingtonDC Pittsburgh Cleveland Detroit Chicago endl;
cout Indianapolis Nashville Atlanta Houston Dallas Austin Denver Albuquerque Phoenix Sacramento" endl;
cout you can repeat this list anytime at prompt by typing locations endl;
cout endl;
void printinst
cout endl;
cout "next" endl;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
