0% found this document useful (0 votes)
103 views6 pages

C++ Project Work

The document is a C++ program for a banking management system created by Apiligu Asakiso. It includes functionalities for creating, modifying, deleting, and displaying account information, as well as depositing and withdrawing money. The program uses file handling to store account data in a binary file format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
103 views6 pages

C++ Project Work

The document is a C++ program for a banking management system created by Apiligu Asakiso. It includes functionalities for creating, modifying, deleting, and displaying account information, as well as depositing and withdrawing money. The program uses file handling to store account data in a binary file format.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

1 //***************************************************************

2 // HEADER FILE USED IN PROJECT


3 //****************************************************************
4 //**************************
5 // NAME: APILIGU ASAKISO ***
6 // ID: FMS/1802/14 ***
7 //**************************
8
9
10 #include<iostream>
11 #include<fstream>
12 #include<cctype>
13 #include<iomanip>
14 using namespace std;
15
16 //***************************************************************
17 // CLASS USED IN PROJECT
18 //****************************************************************
19
20 class account
21 {
22 int acno;
23 char name[50];
24 int deposit;
25 char type;
26 public:
27 void create_account(); //function to get data from user
28 void show_account() const; //function to show data on screen
29 void modify(); //function to add new data
30 void dep(int); //function to accept amount and add to balance amount
31 void draw(int); //function to accept amount and subtract from balance amount
32 void report() const; //function to show data in tabular format
33 int retacno() const; //function to return account number
34 int retdeposit() const; //function to return balance amount
35 char rettype() const; //function to return type of account
36 }; //class ends here
37
38 void account::create_account()
39 {
40 cout<<"\nEnter The account No. : ";
41 cin>>acno;
42 cout<<"\n\nEnter The Name of The account Holder : ";
43 cin.ignore();
44 cin.getline(name,50);
45 cout<<"\nEnter Type of The account (C/S) : ";
46 cin>>type;
47 type=toupper(type);
48 cout<<"\nEnter The Initial amount(>=500 for Saving and >=1000 for current ) : ";
49 cin>>deposit;
50 cout<<"\n\n\nAccount Created..";
51 }
52
53 void account::show_account() const
54 {
55 cout<<"\nAccount No. : "<<acno;
56 cout<<"\nAccount Holder Name : ";
57 cout<<name;
58 cout<<"\nType of Account : "<<type;
59 cout<<"\nBalance amount : "<<deposit;
60 }
61
62
63 void account::modify()
64 {
65 cout<<"\nAccount No. : "<<acno;
66 cout<<"\nModify Account Holder Name : ";
67 cin.ignore();
68 cin.getline(name,50);
69 cout<<"\nModify Type of Account : ";
70 cin>>type;
71 type=toupper(type);
72 cout<<"\nModify Balance amount : ";
73 cin>>deposit;
74 }
75
76
77 void account::dep(int x)
78 {
79 deposit+=x;
80 }
81
82 void account::draw(int x)
83 {
84 deposit-=x;
85 }
86
87 void account::report() const
88 {
89 cout<<acno<<setw(10)<<" "<<name<<setw(10)<<" "<<type<<setw(6)<<deposit<<endl;
90 }
91
92 int account::retacno() const
93 {
94 return acno;
95 }
96
97 int account::retdeposit() const
98 {
99 return deposit;
100 }
101
102 char account::rettype() const
103 {
104 return type;
105 }
106
107
108 //***************************************************************
109 // function declaration
110 //****************************************************************
111 void write_account(); //function to write record in binary file
112 void display_sp(int); //function to display account details given by user
113 void modify_account(int); //function to modify record of file
114 void delete_account(int); //function to delete record of file
115 void display_all(); //function to display all account details
116 void deposit_withdraw(int, int); // function to desposit/withdraw amount for given account
117 void intro(); //introductory screen function
118
119 //***************************************************************
120 // THE MAIN FUNCTION OF PROGRAM
121 //****************************************************************
122
123 int main()
124 {
125 char ch;
126 int num;
127 intro();
128 do
129 {
130
131 cout<<"\n\n\n\tMAIN MENU";
132 cout<<"\n\n\t01. NEW ACCOUNT";
133 cout<<"\n\n\t02. DEPOSIT AMOUNT";
134 cout<<"\n\n\t03. WITHDRAW AMOUNT";
135 cout<<"\n\n\t04. BALANCE ENQUIRY";
136 cout<<"\n\n\t05. ALL ACCOUNT HOLDER LIST";
137 cout<<"\n\n\t06. CLOSE AN ACCOUNT";
138 cout<<"\n\n\t07. MODIFY AN ACCOUNT";
139 cout<<"\n\n\t08. EXIT";
140 cout<<"\n\n\tSelect Your Option (1-8) ";
141 cin>>ch;
142 switch(ch)
143 {
144 case '1':
145 write_account();
146 break;
147 case '2':
148 cout<<"\n\n\tEnter The account No. : "; cin>>num;
149 deposit_withdraw(num, 1);
150 break;
151 case '3':
152 cout<<"\n\n\tEnter The account No. : "; cin>>num;
153 deposit_withdraw(num, 2);
154 break;
155 case '4':
156 cout<<"\n\n\tEnter The account No. : "; cin>>num;
157 display_sp(num);
158 break;
159 case '5':
160 display_all();
161 break;
162 case '6':
163 cout<<"\n\n\tEnter The account No. : "; cin>>num;
164 delete_account(num);
165 break;
166 case '7':
167 cout<<"\n\n\tEnter The account No. : "; cin>>num;
168 modify_account(num);
169 break;
170 case '8':
171 cout<<"\n\n\tThanks for using bank managemnt system";
172 break;
173 default :cout<<"\a";
174 }
175 cin.ignore();
176 cin.get();
177 }while(ch!='8');
178 return 0;
179 }
180
181
182 //***************************************************************
183 // function to write in file
184 //****************************************************************
185
186 void write_account()
187 {
188 account ac;
189 ofstream outFile;
190 outFile.open("account.dat",ios::binary|ios::app);
191 ac.create_account();
192 outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
193 outFile.close();
194 }
195
196 //***************************************************************
197 // function to read specific record from file
198 //****************************************************************
199
200 void display_sp(int n)
201 {
202 account ac;
203 bool flag=false;
204 ifstream inFile;
205 inFile.open("account.dat",ios::binary);
206 if(!inFile)
207 {
208 cout<<"File could not be open !! Press any Key...";
209 return;
210 }
211 cout<<"\nBALANCE DETAILS\n";
212 while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
213 {
214 if(ac.retacno()==n)
215 {
216 ac.show_account();
217 flag=true;
218 }
219 }
220 inFile.close();
221 if(flag==false)
222 cout<<"\n\nAccount number does not exist";
223 }
224
225
226 //***************************************************************
227 // function to modify record of file
228 //****************************************************************
229
230 void modify_account(int n)
231 {
232 bool found=false;
233 account ac;
234 fstream File;
235 File.open("account.dat",ios::binary|ios::in|ios::out);
236 if(!File)
237 {
238 cout<<"File could not be open !! Press any Key...";
239 return;
240 }
241 while(!File.eof() && found==false)
242 {
243 File.read(reinterpret_cast<char *> (&ac), sizeof(account));
244 if(ac.retacno()==n)
245 {
246 ac.show_account();
247 cout<<"\n\nEnter The New Details of account"<<endl;
248 ac.modify();
249 int pos=(-1)*static_cast<int>(sizeof(account));
250 File.seekp(pos,ios::cur);
251 File.write(reinterpret_cast<char *> (&ac), sizeof(account));
252 cout<<"\n\n\t Record Updated";
253 found=true;
254 }
255 }
256 File.close();
257 if(found==false)
258 cout<<"\n\n Record Not Found ";
259 }
260
261 //***************************************************************
262 // function to delete record of file
263 //****************************************************************
264
265
266 void delete_account(int n)
267 {
268 account ac;
269 ifstream inFile;
270 ofstream outFile;
271 inFile.open("account.dat",ios::binary);
272 if(!inFile)
273 {
274 cout<<"File could not be open !! Press any Key...";
275 return;
276 }
277 outFile.open("Temp.dat",ios::binary);
278 inFile.seekg(0,ios::beg);
279 while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
280 {
281 if(ac.retacno()!=n)
282 {
283 outFile.write(reinterpret_cast<char *> (&ac), sizeof(account));
284 }
285 }
286 inFile.close();
287 outFile.close();
288 remove("account.dat");
289 rename("Temp.dat","account.dat");
290 cout<<"\n\n\tRecord Deleted ..";
291 }
292
293 //***************************************************************
294 // function to display all accounts deposit list
295 //****************************************************************
296
297 void display_all()
298 {
299 account ac;
300 ifstream inFile;
301 inFile.open("account.dat",ios::binary);
302 if(!inFile)
303 {
304 cout<<"File could not be open !! Press any Key...";
305 return;
306 }
307 cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n";
308 cout<<"====================================================\n";
309 cout<<"A/c no. NAME Type Balance\n";
310 cout<<"====================================================\n";
311 while(inFile.read(reinterpret_cast<char *> (&ac), sizeof(account)))
312 {
313 ac.report();
314 }
315 inFile.close();
316 }
317
318 //***************************************************************
319 // function to deposit and withdraw amounts
320 //****************************************************************
321
322 void deposit_withdraw(int n, int option)
323 {
324 int amt;
325 bool found=false;
326 account ac;
327 fstream File;
328 File.open("account.dat", ios::binary|ios::in|ios::out);
329 if(!File)
330 {
331 cout<<"File could not be open !! Press any Key...";
332 return;
333 }
334 while(!File.eof() && found==false)
335 {
336 File.read(reinterpret_cast<char *> (&ac), sizeof(account));
337 if(ac.retacno()==n)
338 {
339 ac.show_account();
340 if(option==1)
341 {
342 cout<<"\n\n\tTO DEPOSITE AMOUNT ";
343 cout<<"\n\nEnter The amount to be deposited";
344 cin>>amt;
345 ac.dep(amt);
346 }
347 if(option==2)
348 {
349 cout<<"\n\n\tTO WITHDRAW AMOUNT ";
350 cout<<"\n\nEnter The amount to be withdraw";
351 cin>>amt;
352 int bal=ac.retdeposit()-amt;
353 if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C'))
354 cout<<"Insufficience balance";
355 else
356 ac.draw(amt);
357 }
358 int pos=(-1)*static_cast<int>(sizeof(ac));
359 File.seekp(pos,ios::cur);
360 File.write(reinterpret_cast<char *> (&ac), sizeof(account));
361 cout<<"\n\n\t Record Updated";
362 found=true;
363 }
364 }
365 File.close();
366 if(found==false)
367 cout<<"\n\n Record Not Found ";
368 }
369
370
371 //***************************************************************
372 // INTRODUCTION FUNCTION
373 //****************************************************************
374
375 void intro()
376 {
377 cout<<"\n\n\n\t BANK";
378 cout<<"\n\n\tMANAGEMENT";
379 cout<<"\n\n\t SYSTEM";
380 cout<<"\n\n\n\nMADE BY : APILIGU ASAKISO ";
381 cout<<"\n\nSCHOOL : UNIVERSITY FOR DEVELOPMENT STUDIES ";
382 cin.get();
383 }
384
385 //***************************************************************
386 // END OF PROJECT
387 //***************************************************************

You might also like