-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLMS.cpp
More file actions
153 lines (115 loc) · 2.98 KB
/
LMS.cpp
File metadata and controls
153 lines (115 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#include<bits/stdc++.h>
using namespace std;
void bookdb(map<int,pair<string,char> > books)
{
map<int,pair<string,char> >::iterator it;
for(it=books.begin();it!=books.end();it++)
{
cout<<it->first<<" "<<(it->second).first<<" "<<(it->second).second<<endl;
}
}
void subdb(map<int,pair<string,list<string> > > subs)
{
map<int,pair<string,list<string> > >::iterator it1;
list<string>::iterator it2;
for(it1=subs.begin();it1!=subs.end();it1++)
{
cout<<"Books borrowed by "<<" "<<(it1->second).first<<" "<<it1->first<<" "<<"are"<<endl;
for(it2=((it1->second).second).begin();it2!=((it1->second).second).end();it2++)
{
cout<<*it2<<endl;
}
}
}
void addbook(map<int,pair<string,char> > books)
{
int acc;
string title;
char tag;
cout<<"Enter the accesion number"<<endl;
cin>>acc;
cout<<"Enter the title"<<endl;
cin>>title;
cout<<"Book borrowed or not (Y/N)"<<endl;
cin>>tag;
books[acc]=make_pair(title,tag);
cout<<"Updated book db"<<endl;
bookdb(books);
}
void bookissue(map<int,pair<string,char> > books)
{
map<int,pair<string,char> >::iterator it;
int accno;
bookdb(books);
cout<<"Enter the accesion no of the book to be issued"<<endl;
cin>>accno;
it = books.find(accno);
(it->second).second='Y';
bookdb(books);
}
int main()
{
map<int,pair<string,char> > books;
int n1;
cout<<"Enter the number of books to be stored in database"<<endl;
cin>>n1;
for(int k=0;k<n1;k++)
{
int acc;
string title;
char tag;
cout<<"Enter the accesion number of "<<k+1<<" book"<<endl;
cin>>acc;
cout<<"Enter the title of "<<k+1<<" book"<<endl;
cin>>title;
cout<<"Book borrowed or not (Y/N)"<<endl;
cin>>tag;
books[acc]=make_pair(title,tag);
}
map<int,pair<string,list<string> > > subs;
int n2;
cout<<"Enter the number of subscribers to be stored in database"<<endl;
cin>>n2;
for(int j=0;j<n2;j++)
{
int sno,bno;
string name,title;
cout<<"Enter the subscriber number of subscriber "<<j+1<<endl;
cin>>sno;
cout<<"Enter the name of subscriber"<<endl;
cin>>name;
cout<<"Enter the number of books subscriber has borrowed"<<endl;
cin>>bno;
list<string> book;
for(int i=0;i<bno;i++)
{
cout<<"Enter the title of book number "<<i+1<<" for subscriber number "<<j+1<<endl;
cin>>title;
book.push_front(title);
}
subs[sno]=make_pair(name,book);
}
system("CLS");
while(1)
{
int choice;
cout<<" 1. Book Database\n 2. Subscriber Database\n 3. Book Issue\n 4. Book Submission"<<endl;
cin>>choice;
switch(choice)
{
case 1:
bookdb(books);
break;
case 2:
subdb(subs);
break;
case 3:
bookissue(books);
break;
case 4:
addbook(books);
break;
default: ;
}
}
}