diff --git a/BANK MANAGEMENT SYSTEM.docx b/BANK MANAGEMENT SYSTEM.docx new file mode 100644 index 0000000..62a2865 Binary files /dev/null and b/BANK MANAGEMENT SYSTEM.docx differ diff --git a/Bank_Management_System.cpp b/Bank_Management_System.cpp new file mode 100644 index 0000000..9b48e38 --- /dev/null +++ b/Bank_Management_System.cpp @@ -0,0 +1,382 @@ +#include +#include +#include +#include +#include +#include +#include +#include +using namespace std; + +int date() +{ + time_t now = time(0); + tm *ltm = localtime(&now); + cout<<"DATE : "; + cout<tm_mday <<"-"<<1 + ltm->tm_mon<<"-"<<1900 + ltm->tm_year<0;x--) + { + a=rand()%x; + cout<>Bdate; + cin>>Bmonth; + cin>>Byear; + if(Bdate<1 || Bdate>31 || Bmonth<1 || Bmonth>12) + { + cout<<"Enter valid Date Of Birth :"; + goto backtodate; + } + cout<<"Enter Your Address in single line :"; + cin.ignore(); + cin.getline(address,999); + cout<<"Enter your Contact Number(10 digit only):"; + cin>>contact; + + cout<<"Your account number :"; + acc_number(); + cout<<"Enter your account number given for confirmation :"; + cin>>ac_number; + + cout<<"Enter pin you want to set:"; + cin>>pin; + + cout<<"Enter some depositary money(min 1000) :"; + cin>>mne; + while(mne<=1000) + { + cout<>mne; + if(mne>=1000) + break; + } + + } + void showaccountdata() + { + cout<>ans; + /*if(!strcmp(ans,"NO")) + cout<>Fname; + }*/ + cout<>ans; + if(!strcmp(ans,"NO")) + cout<>contact; + } + + cout<>ans; + if(!strcmp(ans,"NO")) + cout<>d_mne; + mne=d_mne+mne; + cout<<"Enter withdrawal amount:"; + cin>>w_mne; + mne=mne-w_mne; + cout<<"Current balance of this account: "<>pin2; + backtopin:; + if(pin2==(*this).pin) + { + showaccountdata(); + cnt++; + } + else + { + cout<<"Enter YES or NO if you remember the pin:"; + cin.ignore(); + cin.getline(dcision,4); + if(!strcmp(dcision,"YES")) + { + cout<<"Enter valid pin:"; + cin>>pin2; + goto backtopin; + } + else + { + cout<<"Sorry we cannot help you, Contact BANK HELP CENTRE."; + goto out; + } + } + } + fin.read((char*)this,sizeof(*this)); + } + } + if(cnt==0) + { + cout<<"\n Error..! Account not found"; + } + out:; + fin.close(); +} +void account::deleteaccount(long double *t,int *pin2) +{ + long double temp_num; + int temp_pin; + ifstream fin; + ofstream fout; + fin.open("file.dat",ios::out|ios::binary); + if(!fin) + cout<<"\n File not found"; + else{ + fout.open("temp.dat",ios::out|ios::binary); + fin.read((char*)this,sizeof(*this)); + while(!fin.eof()) + { + if(*t!=ac_number) + { + if(*pin2!=pin) + { + fout.write((char*)this,sizeof(*this)); + } + } + else + { + temp_num=ac_number; + temp_pin=pin; + + } + fin.read((char*)this,sizeof(*this)); + } + if(*t==temp_num && *pin2==temp_pin) + { + cout<<"Account is deleted & COLLECT your CASH FROM DESK."; + fin.close(); + fout.close(); + remove("file.dat"); + rename("temp.dat","file.dat"); + } + else + { + cout<<"Account number or pin is invalid."; + fin.close(); + fout.close(); + } + } +} +void account::updateaccount(long double *t) +{ + int pin2; + char dcision[4]; + fstream file; + file.open("file.dat",ios::in|ios::out|ios::binary|ios::ate); + file.seekg(0); + file.read((char*)this,sizeof(*this)); + while(!file.eof()) + { + if(*t==ac_number) + { + cout<<"Enter pin:"; + cin>>pin2; + if(pin2==(*this).pin) + { + newgetaccountdata(); + file.seekp(file.tellp()-sizeof(*this)); + file.write((char*)this,sizeof(*this)); + } + else + { + cout<<"Sorry we cannot help you."<**** Bank management ****<--"; + cout< 1. Insert a bank account."; + cout<<"\n\t--> 2. View all bank accounts."; + cout<<"\n\t--> 3. Search a bank account."; + cout<<"\n\t--> 4. Delete a bank account."; + cout<<"\n\t--> 5. Update a bank account."; + cout<<"\n\t--> 6. Exit"; + cout<<"\n\n Enter a choice :"; + cin>>choice; + return choice; +} +int main() +{ + account b1; + while(1) + { + + system("cls"); + switch(menu()) + { + case 1: + + b1.getaccountdata(); + b1.storeaccountdata(); + cout<<"Account is created."; + break; + case 2: + + b1.viewallaccount(); + break; + case 3: + + cout<<"Enter account number to search :"; + long double atemp; + cin.ignore(); + cin>>atemp; + b1.searchaccount(&atemp); + break; + case 4: + + int pin2; + cout<<"Enter account number to delete account :"; + cin>>atemp; + cout<<"Enter pin : "; + cin>>pin2; + b1.deleteaccount(&atemp,&pin2); + break; + case 5: + + cout<<"Enter account number to update account :"; + cin>>atemp; + b1.updateaccount(&atemp); + break; + case 6: + + cout<<"Thank you for using this application"; + cout<<"\nPress any key to continue"; + _getch(); + system("cls"); + exit(0); + break; + default: + + cout<<"\nInvalid Choice"; + } + _getch(); + } +}