You are on page 1of 7

Bank Management System

Team-08
Team Name: Revampers
Team leader: Pratik Thakare

Code:

1 # include<iostream>
2 # include<conio.h>
3 #include<cstdlib>
4 using namespace std;
5
6 class bank
7 {
8 private:
9
10 string name;
11 int acno;
12 char actype;//S or C
13 float balance;
14 bank* next;
15
16 public:
17
18 bank(int accno,int actype,string name,float balance)
19 {
20 this->acno =accno;
21 this->actype = actype;
22 this->name = name;
23 this->balance = balance;
24 next = nullptr;
25 }
26
27 friend class Linkedlist;
28 };
29
30 class Linkedlist
31 {
32
33 private:
34
35 bank* head;
36
37 public:
38
39 Linkedlist()
40 {
41 head = nullptr;
42 }
43
44 void Add_Account(int acno,char type,string name,float amount)
45 {
46
47 bank* b = new bank(acno,type,name,amount);
48 bank* temp = head;
49
50 if(head == nullptr)
51 {
52 head = b;
53 return;
54 }
55
56 while(temp!=nullptr && temp->acno!=acno)
57 {
58 temp = temp->next;
59 }
60
61 if(temp == nullptr)
62 {
63
64 temp = head;
65 b->next = temp;
66 head = b;
67 return;
68
69 }
70
71 cout<<"ACCOUNT NO IS PRESENT ALREADY"<<endl;
72 return ;
73
74 }
75
76 void deposit(int acno,float amount)
77 {
78
79 if(head == nullptr)
80 {
81 cout<<"NO DATA TO DO DEPOSIT"<<endl;
82 return;
83 }
84
85 bank* temp = head;
86
87 while(temp!=nullptr && temp->acno!=acno)
88 {
89 temp = temp->next;
90 }
91
92 if(temp == nullptr)
93 {
94 cout<<"DATA NOT FOUND"<<endl;
95 return ;
96 }
97
98 temp->balance += amount;
99 }
100
101 void withdraw(int acno, float amount)
102 {
103
104 if(head == nullptr)
105 {
106 cout<<"NO DATA TO DO WITHDRAW "<<endl;
107 return;
108 }
109
110 bank* temp = head;
111
112 while(temp!=nullptr && temp->acno!=acno)
113 {
114 temp = temp->next;
115 }
116
117 if(temp == nullptr)
118 {
119 cout<<"DATA NOT FOUND"<<endl;
120 return ;
121 }
122
123 temp->balance -= amount;
124 }
125
126 void Search_Acc_Details(int acno)
127 {
128
129 if(head == nullptr)
130 {
131 cout<<"NO DATA TO SEARCH"<<endl;
132 return;
133 }
134
135 bank* temp = head;
136
137 while(temp!=nullptr && temp->acno!=acno)
138 {
139 temp = temp->next;
140 }
141
142 if(temp == nullptr)
143 {
144 cout<<"Data Not Found"<<endl;
145 return ;
146 }
147
148 cout<<"Account Details"<<endl;
149 cout<<"Name of the depositor : "<<temp->name<<endl;
150 cout<<"Account Number : "<<temp->acno<<endl;
151 cout<<"Account Type : "<<temp->actype<<endl;
152 cout<<"Balance : "<<temp->balance<<endl;
153 }
154
155 void Show_All_Details()
156 {
157
158 if(head == nullptr)
159 {
160 cout<<"NO DATA TO SHOW"<<endl;
161 return;
162 }
163
164 bank* temp = head;
165
166 while(temp!=nullptr)
167 {
168 cout<<"Name of the depositor : "<<temp->name<<endl;
169 cout<<"Account Number : "<<temp->acno<<endl;
170 cout<<"Account Type : "<<temp->actype<<endl;
171 cout<<"Balance : "<<temp->balance<<endl;
172 temp = temp->next;
173 }
174 }
175
176 void Modify_Details(int acno)
177 {
178
179 if(head == nullptr)
180 {
181 cout<<"NO DATA TO MODIFY"<<endl;
182 return;
183 }
184
185 bank* temp = head;
186
187 while(temp!=nullptr && temp->acno!=acno)
188 {
189 temp = temp->next;
190 }
191
192 if(temp == nullptr)
193 {
194 cout<<"ACCOUNT NO NOT FOUND"<<endl;
195 return ;
196 }
197
198 cout<<"Enter the New Name of the depositor : ";
199 cin>>temp->name;
200 cout<<"Enter the New Amount to Deposit : ";
201 cin >>temp->balance;
202
203 }
204 };
205
206 // main function , exectution starts here
207 int main(void)
208 {
209 system("CLS");
210 Linkedlist l1;
211 int choice =1;
212 int acno;
213 string name;
214 char actype;
215 float balance,amount;
216
217 while (choice != 0 )
218 {
219 cout<<"\n \t\t\t\tEnter 0 to exit\n\t\t\t\t1). Add Account.\n\t\t\t\t"
220 <<"2). Deposit\n\t\t\t\t3).Withdraw\n\t\t\t\t4).See A/c Details\n"
221 <<"\t\t\t\t5).Modify Account details\n\t\t\t\t”
<<”6).Show All Account details\n"<<endl;
222 ` cin>>choice;
223
224 switch(choice)
225 {
226
227 case 0 : cout<<"EXITING PROGRAM.";
228 break;
229
230 case 1 : cout<<"Enter the Name of the depositor : ";
231 cin>>name;
232 cout<<"Enter the Account Number : ";
233 cin>>acno;
234 cout<<"Enter the Account Type : (C/S) ";
235 cin>>actype;
236 cout<<"Enter the Amount to Deposit : ";
237 cin >>balance;
238 l1.Add_Account(acno,actype,name,balance);
239 break;
240
241 case 2: cout<<"Enter the Account Number : ";
242 cin>>acno;
243 cout<<"Enter the Amount to Deposit : ";
244 cin >>amount;
245 l1.deposit(acno,amount);
246 break;
247
248 case 3 : cout<<"Enter the Account Number : ";
249 cin>>acno;
250 cout<<"Enter the Amount to Withdraw : ";
251 cin >>amount;
252 l1.withdraw(acno,amount);
253 break;
254
255 case 4 : cout<<"Enter the Account Number : ";
256 cin>>acno;
257 l1.Search_Acc_Details(acno);
258 break;
259
260 case 5 : cout<<"Enter the Account Number : ";
261 cin>>acno;
262 l1.Modify_Details(acno);
263 break;
264
265 case 6 : l1.Show_All_Details();
266 break;
267
268 default: cout<<"INVALID OPTION"<<endl;
269 }
270 }
271
272 getch();
273}
274

Output:

You might also like