#Include Using Namespace Int
#Include Using Namespace Int
h>
using namespace std;
int main() {
string x;
cout<<"Enter name : ";
cin>>x;
cout<<"\n";
map<int , string > mp;
mp.insert({10,"BOOK1"});
mp.insert({20,"BOOK2"});
mp.insert({30,"BOOK3"});
mp.insert({40,"BOOK4"});
int flag=0;
int input;
while(flag==0){
cout<<"Hello "<<x<<",\nWelcome to Libraby Manager\n";
cout<<"Select a task to perform:\n";
cout<<"1. Take a book\n";
cout<<"2. Donate a book\n";
cout<<"3. Check books\n";
cout<<"4. EXIT\n";
cin>>input;
cout<<"-------------------\n";
switch(input)
{
case 1:
{
int bn;
cout<<"Enter book number: ";
cin>>bn;
if(mp.count(bn) > 0)
{
cout<<mp[bn]<<" taken!\n";
mp.erase(bn);
}
else
{
cout<<"Book not found...\n";
}
}
break;
case 2:
{
int bn;
string name;
cout<<"Enter book number: ";
cin>>bn;
cout<<endl;
cout<<"Enter book name: ";
cin>>name;
cout<<endl;
if ( mp.count(bn)>0 ) {
cout<<"Book with same book number already exists!\n";
}
else {
mp.insert({ bn, name });
cout<<"Book Added!\n\n";
}
}
break;
case 3:
{
cout<<"Here are the books:\n";
map<int, string>::iterator it;
for ( it = mp.begin(); it != mp.end(); it++ )
{
cout << it->first
<< " : "
<< it->second // string's value
<<endl ;
}
cout<<endl;
cout<<"-------------------\n";
}
break;
case 4: {cout<<"Bye "<<x;flag=1;}
break;
default:cout<<"Enter proper values -_- \n\n";
}
}
return 0;
}