Each item that bakery sells has name of type std::string
and price of type double
. The user inputs the names and prices. The input ends when the user provides the word endOfInput
instead of a name for an item. Create a program that checks whether chocolateDonut
is in the map. If it is, then the program should print its price. If chocolateDonut
is not in the map, then the program should print Not found
.
Your code should replace the text // ??? //
below.
#include<iostream> #include "simple_set_and_map.cpp" int main(){ ssm::map<std::string, double> bakery; std::string itemFromUser; double priceFromUser; std::cin>>itemFromUser; while(itemFromUser!="endOfInput"){ std::cin>>priceFromUser; bakery.insert(itemFromUser,priceFromUser); std::cin>>itemFromUser; } // ??? // return 0; }