Write, compile and run a program that works some of the functionality provided by the C++ map container. Read data from a file into your map and produce various outcomes listed below via various...


Write, compile and run a program that works some of the functionality provided by the C++ map container. Read data from a file into your map and produce various outcomes listed below via various user-defined methods. Use a menu for user friendliness.




Write, compile and run a program that works some of the functionality provided by the C++ map container. Read data from a file into your map and produce various outcomes listed below via various user-defined methods. Use a menu for user friendliness. The file spec includes for each record a last name followed by a first name for each names. Each row value will thus serve as a key value pair for our map where the map key will be unique being the person last name and the first name will be the value for the map (wMap). Take your names.txt file accompanying this lab and place it into your root folder along with the source provided in word document. Include a menu to allow for the following 1. Search Person for first name (i.e., by key) 1. Remove Person (i.e., by key) 1. Update Person (i.e., to change value by key) 1. Get Person count 1. Print all People(First name first, Last name second) 1. Exit application (display message such as “Good bye/stay safe”) Include appropriate methods that will be triggered by each menu selection by the user. Example follows for a Search routine. Method definition example (passed by reference) void search(map &map, string key) { std::cout < "search="" result=""> " < map.find(key)-="">second; } Method call example search(wMap,"Short"); Helper functions that map has include: find(some key) erase(some key) size() count(some key) -checks if key exists. 1 is returned for true, 0 for false Get user input for a key for example where applicable from your menu choices and trigger the appropriate response. For menu item #3 above search for the key “Medina”. Change the value to “Martin” as the name was misspelled in the file! Starter Code: #include #include #include #include

using namespace std; int main() { ifstream ifp("names.txt"); map wMap; //create map string key, val; while( ifp>>key>>val) wMap.insert(make_pair(key,val)); //populate map cout < "wmap.size()=" << wMap.size() << endl; for(auto it = wMap.begin(); it != wMap.end(); it++) cout << it->first << " "="">< it-="">second < endl;="" return="" 0;="">
Apr 22, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here