#include #include #include //for class string #include //for class vector #include //for class map using namespace std; int main() { map> m { {"Honda", {"Red", "Blue", "Black"}}, {"Toyota", {"White", "Silver", "Green"}} }; string carModel; cout << "What is the model of the car (one of the following)?\n"; for (auto& pair: m) { cout << "\t" << pair.first << "\n"; //the name of each model } cout << "Model? "; cin >> carModel; if (!cin) { cerr << "Sorry, could not receive input.\n"; return EXIT_FAILURE; } auto it {m.find(carModel)}; //Look up the model the user asked for. if (it == m.end()) { cerr << "Sorry, that wasn't a valid car model.\n" << "Please enter one of the following:\n"; for (auto& pair: m) { cerr << "\t" << pair.first << "\n"; } return EXIT_FAILURE; } cout << "The available colors for the " << it->first << " are:\n"; auto v {it->second}; //Get the vector of colors for our model. for (int i {0}; i < v.size(); ++i) { cout << i+1 << ". " << v[i] << "\n"; } return EXIT_SUCCESS; }