#include <iostream>
#include <map>
int main() {
std::map<std::string, float> myMap;
// Inserting values into the map
myMap["Apple"] = 2.5;
myMap["Banana"] = 1.8;
myMap["Orange"] = 3.2;
// Accessing values in the map
std::cout << "Price of Apple: " << myMap["Apple"] << std::endl;
// Modifying values in the map
myMap["Banana"] = 2.0;
// Checking if a key exists in the map
if (myMap.find("Grapes") != myMap.end()) {
std::cout << "Price of Grapes: " << myMap["Grapes"] << std::endl;
} else {
std::cout << "Grapes not found in the map." << std::endl;
}
// Iterating through the map
for (const auto& pair : myMap) {
std::cout << pair.first << ": " << pair.second << std::endl;
}
return 0;
}