📄 a project of bank.cpp
字号:
//**********************************************************
// PROJECT BANKING
//**********************************************************
//**********************************************************
// BY MUHAMMAD AWAIS RAZA
// Project For 2nd Smester
//**********************************************************
#include <iostream.h>
#include <fstream.h>
#include <process.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <conio.h>
#include <dos.h>
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO DRAW BOX ETC.
//**********************************************************
class shape
{
public :
void line_hor(int, int, int, char) ;
void line_ver(int, int, int, char) ;
void box(int,int,int,int,char) ;
} ;
//**********************************************************
// THIS CLASS CONTROL ALL THE FUNCTIONS IN THE MENU
//**********************************************************
class control
{
public :
void main_menu(void) ;
void help(void) ;
private :
void edit_menu(void) ;
} ;
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO INITIAL DEPOSIT
//**********************************************************
class initial
{
public :
void add_to_file(int, char t_name[30], char t_address[60], float) ;
void display_list(void) ;
void delete_account(int) ;
void update_balance(int, float) ;
void modify(void) ;
int last_accno(void) ;
int found_account(int) ;
char *return_name(int) ;
char *return_address(int) ;
float give_balance(int) ;
int recordno(int) ;
void display(int) ;
private :
void modify_account(int, char t_name[30], char t_address[60]) ;
void box_for_list(void) ;
int accno ;
char name[30], address[60] ;
float balance ;
} ;
//**********************************************************
// THIS CLASS CONTAINS FUNCTIONS RELATED TO TRANSACTIONS
//**********************************************************
class account
{
public :
void new_account(void) ;
void close_account(void) ;
void display_account(void) ;
void transaction(void) ;
void clear(int,int) ;
private :
void add_to_file(int, int, int, int, char, char t_type[10], float, float, float) ;
void delete_account(int) ;
int no_of_days(int, int, int, int, int, int) ;
float calculate_interest(int, float) ;
void display(int) ;
void box_for_display(int) ;
int accno ;
char type[10] ; // Cheque or Cash //
int dd, mm, yy ; // Date //
char tran ; // Deposit or Withdraw //
float interest, amount, balance ;
} ;
//**********************************************************
// FUNCTION TO DRAW HORIZONTAL LINE
//**********************************************************
void shape :: line_hor(int column1, int column2, int row, char c)
{
for ( column1; column1<=column2; column1++ )
{
gotoxy(column1,row) ;
cout <<c ;
}
}
//**********************************************************
// FUNCTION TO DRAW VERTICAL LINE
//**********************************************************
void shape :: line_ver(int row1, int row2, int column, char c)
{
for ( row1; row1<=row2; row1++ )
{
gotoxy(column,row1) ;
cout <<c ;
}
}
//**********************************************************
// FUNCTION TO DRAW BOX LINE
//**********************************************************
void shape :: box(int column1, int row1, int column2, int row2, char c)
{
char ch=218 ;
char c1, c2, c3, c4 ;
char l1=196, l2=179 ;
if (c == ch)
{
c1=218 ;
c2=191 ;
c3=192 ;
c4=217 ;
l1 = 196 ;
l2 = 179 ;
}
else
{
c1=c ;
c2=c ;
c3=c ;
c4=c ;
l1 = c ;
l2 = c ;
}
gotoxy(column1,row1) ;
cout<<c1 ;
gotoxy(column2,row1) ;
cout <<c2 ;
gotoxy(column1,row2) ;
cout <<c3 ;
gotoxy(column2,row2) ;
cout <<c4 ;
column1++ ;
column2-- ;
line_hor(column1,column2,row1,l1) ;
line_hor(column1,column2,row2,l1) ;
column1-- ;
column2++ ;
row1++ ;
row2-- ;
line_ver(row1,row2,column1,l2) ;
line_ver(row1,row2,column2,l2) ;
}
//**********************************************************
// FUNCTION TO DISPLAY MAIN MENU AND CALL OTHER FUNCTIONS
//**********************************************************
void control :: main_menu(void)
{
char ch ;
while (1)
{
clrscr() ;
shape s ;
s.box(10,5,71,21,219) ;
s.box(9,4,72,22,218) ;
textcolor(BLACK) ;
textbackground(YELLOW) ;
gotoxy(32,21);cprintf(" MUHAMMAD AWAIS RAZA ");
gotoxy(32,25);cprintf(" LOGIC EYE DEVELOPERS ");
textcolor(CYAN) ;
textbackground(BLUE) ;
gotoxy(32,7) ;
cprintf(" B A N K I N G ") ;
gotoxy(35,9) ;
cprintf(" OPTIONS ") ;
textcolor(YELLOW) ;
textbackground(BLACK) ;
gotoxy(30,11) ;
cout <<"1: SEE ACCOUNT" ;
gotoxy(30,12) ;
cout <<"2: LIST OF ACCOUNTS" ;
gotoxy(30,13) ;
cout <<"3: TRANSACTIONS" ;
gotoxy(30,14) ;
cout <<"4: OPEN NEW ACCOUNT" ;
gotoxy(30,15) ;
cout <<"5: EDIT ACCOUNTS" ;
gotoxy(30,16) ;
cout <<"6: HELP" ;
gotoxy(30,17) ;
cout <<"0: QUIT" ;
gotoxy(30,19) ;
cout <<"Enter your choice: " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
account a ;
a.display_account() ;
}
else
if (ch == '2')
{
initial ini ;
ini.display_list() ;
}
else
if (ch == '3')
{
account a ;
a.transaction() ;
}
else
if (ch == '4')
{
account a ;
a.new_account() ;
}
else
if (ch == '5')
edit_menu() ;
else
if (ch == '6')
help() ;
else
if (ch == '0')
break ;
}
for (int i=25; i>=1; i--)
{
delay(40) ;
gotoxy(1,i) ; clreol() ;
}
}
//**********************************************************
// FUNCTION TO DISPLAY EDIT MENU AND CALL OTHER FUNCTIONS
//**********************************************************
void control :: edit_menu(void)
{
char ch ;
while (1)
{
clrscr() ;
shape s ;
s.box(10,5,71,21,219) ;
s.box(9,4,72,22,218) ;
textcolor(RED) ;
textbackground(BLUE) ;
gotoxy(34,10) ;
cprintf(" EDIT MENU ") ;
textcolor(YELLOW) ;
textbackground(BLACK) ;
gotoxy(31,12) ;
cout <<"1: MODIFY ACCOUNT" ;
gotoxy(31,13) ;
cout <<"2: CLOSE ACCOUNT" ;
gotoxy(31,14) ;
cout <<"0: QUIT" ;
gotoxy(31,16) ;
cout <<"Enter your choice: " ;
ch = getche() ;
if (ch == 27)
break ;
else
if (ch == '1')
{
initial ini ;
ini.modify() ;
break ;
}
else
if (ch == '2')
{
account a ;
a.close_account() ;
break ;
}
else
if (ch == '0')
break ;
}
}
//**********************************************************
// FUNCTION TO DISPLAY HELP ABOUT PROJECT
//**********************************************************
void control :: help(void)
{
clrscr() ;
textcolor(RED+BLINK) ;textbackground(GREEN);
gotoxy(18,2); cprintf(" P R O J E C T B A N K I N G OF P U N J A B ") ;
textcolor(BLACK);
gotoxy(18,4); cprintf(" By- MUHAMMAD AWAIS RAZA (Logic eye Developers)");
delay(10) ;
gotoxy(10,6); cout <<"In this Project you can keep records of daily banking" ;
delay(10) ;
gotoxy(10,7); cout <<"transactions. " ;
delay(10) ;
gotoxy(10,9); cout <<" This program is capable of holding any no. of accounts." ;
delay(10) ;
gotoxy(10,11); cout <<"- In the first option you can see the account of a particular" ;
delay(10) ;
gotoxy(10,12); cout <<" person by giving simply the account no. of that person." ;
delay(10) ;
gotoxy(10,14); cout <<"- In second option you can see the list of all the accounts." ;
delay(10) ;
gotoxy(10,16); cout <<"- Through third option you can operate banking transactions" ;
delay(10) ;
gotoxy(10,17); cout <<" (Deposit/Withdraw)." ;
delay(10) ;
gotoxy(10,19); cout <<"- In Fourth option you can open new account." ;
delay(10) ;
gotoxy(10,20); cout <<" (NOTE: Opening amount should not be less than Rs.500/-)" ;
delay(10) ;
gotoxy(10,22); cout <<"- In Fifth option you can modify or Delete any of the accounts." ;
delay(10) ;
gotoxy(10,24); cout <<"- And the last option is to Quit the PROJECT (Exit to Dos). " ;
delay(10) ;
textcolor(MAGENTA+BLINK) ; textbackground(LIGHTGREEN) ;
gotoxy(26,30) ; cprintf(" Press any key to continue ") ;
textcolor(YELLOW) ; textbackground(BLACK) ;
gotoxy(25,2) ;
getch() ;
for (int i=25; i>=1; i--)
{
delay(50) ;
gotoxy(1,i) ; clreol() ;
}
}
//**********************************************************
// THIS FUNCTION RETURN LAST ACCOUNT NO. IN THE FILE
// INITIAL.DAT
//**********************************************************
int initial :: last_accno(void)
{
fstream file ;
file.open("INITIAL.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(initial)))
count = accno ;
file.close() ;
return count ;
}
//**********************************************************
// THIS FUNCTION RETURN RECORD NO. OF THE GIVEN ACCOUNT NO.
// IN THE FILE INITIAL.DAT
//**********************************************************
int initial :: recordno(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
int count=0 ;
while (file.read((char *) this, sizeof(initial)))
{
count++ ;
if (t_accno == accno)
break ;
}
file.close() ;
return count ;
}
//**********************************************************
// THIS FUNCTION DISPLAY THE ACCOUNT FOR GIVEN ACCOUNT NO.
// FROM THE FILE INITIAL.DAT
//**********************************************************
void initial :: display(int t_accno)
{
shape s ;
s.box(8,7,73,11,219) ;
fstream file ;
file.open("INITIAL.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
while (file.read((char *) this, sizeof(initial)))
{
if (t_accno == accno)
{
gotoxy(8,5) ;
cout <<"ACCOUNT NO. " <<accno ;
gotoxy(10,8) ;
cout <<"Name : "<<name ;
gotoxy(10,9) ;
cout <<"Address : " <<address ;
gotoxy(10,10) ;
cout <<"Balance : " <<balance ;
break ;
}
}
file.close() ;
}
//**********************************************************
// THIS FUNCTION RETURN NAME FOR THE GIVEN ACCOUNT NO.
// IN THE FILE INITIAL.DAT
//**********************************************************
char *initial :: return_name(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char t_name[30] ;
while (file.read((char *) this, sizeof(initial)))
{
if (accno == t_accno)
{
strcpy(t_name,name) ;
break ;
}
}
file.close() ;
return t_name ;
}
//**********************************************************
// THIS FUNCTION RETURN ADDRESS FOR THE GIVEN ACCOUNT NO.
// IN THE FILE INITIAL.DAT
//**********************************************************
char *initial :: return_address(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
char t_address[60] ;
while (file.read((char *) this, sizeof(initial)))
{
if (accno == t_accno)
{
strcpy(t_address,address) ;
break ;
}
}
file.close() ;
return t_address ;
}
//**********************************************************
// THIS FUNCTION RETURN BALANCE FOR THE GIVEN ACCOUNT NO.
// IN THE FILE INITIAL.DAT
//**********************************************************
float initial :: give_balance(int t_accno)
{
fstream file ;
file.open("INITIAL.DAT", ios::in) ;
file.seekg(0,ios::beg) ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -