Anda di halaman 1dari 8

//***************************************************************

//
HEADER FILE USED IN PROJECT
//****************************************************************
#include<graphics.h>
#include<fstream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<string.h>
#include<ctype.h>
#include<dos.h>
//***************************************************************
//
CLASS USED IN PROJECT
//****************************************************************
class account
{
double acno, deposit, withdraw;
char name[50];
char type;
public:
void create_account()
{
cout<<"\n\n====NEW ACCOUNT ENTRY FORM====\n\n";
cout<<"\nEnter The account Number : ";
cin>>acno;
cout<<"\nEnter The Name of The account Holder : ";
gets(name);
cout<<"\nEnter Type of The account (C/S) : ";
cin>>type;

cout<<"\nEnter Initial amount\n>=500 for Saving >=1000 for current :";


cin>>deposit;
cout<<"\n\n\nYour Account Created Successfully ..";
}
void show_account()
{
cout<<"\n\n----ACCOUNT STATUS----\n";
cout<<"\nAccount No. : "<<acno;
cout<<"\nAccount Holder Name : "<<name;
cout<<"\nType of Account : "<<type;
cout<<"\nBalance amount : "<<deposit;
}
void modify_account()
{
cout<<"\nAccount No. : "<<acno;
cout<<"\nModify Account Holder Name : ";
cin>>name;
cout<<"Modify Type of Account : ";cin>>type;
cout<<"Modify Balance amount : ";cin>>deposit;
}
void dep(int x)
{

deposit+=x;
}
void draw(int x)
{
deposit-=x;
}
void report()
{
cout<<acno<<"\t"<<name<<"\t\t"<<type<<"\t\t"<<deposit<<endl;
}
int retacno()
{
return acno;
}
float retdeposit()
{
return deposit;
}
char rettype()
{
return type;
}
};
//class ends here
//***************************************************************
//
global declaration for stream object, object
//****************************************************************

fstream fp;
account ac;
//***************************************************************
//
function to write in file
//****************************************************************
void write_account()
{
fp.open("account.dat",ios::in|ios::app);
ac.create_account();
fp.write((char*)&ac,sizeof(account));
fp.close();
}
//***************************************************************
//
function to read specific record from file
//****************************************************************

void display_sp()
{
int n;
cout<<"\n\n====BALANCE DETAILS====";
cout<<"\n\nEnter the Account Number : ";
cin>>n;

int flag=0;
fp.open("account.dat",ios::in);
while(fp.read((char*)&ac,sizeof(account)))
{
if(ac.retacno()==n)
{
ac.show_account();
flag=1;
}
}
fp.close();
if(flag==0)
cout<<"\n\nAccount Number does not exist";
getch();
}
//***************************************************************
//
function to modify record of file
//****************************************************************
void modify_account()
{
int no,found=0;
cout<<"\n\n====MODIFY RECORD====";
cout<<"\n\nEnter the Account No. : ";
cin>>no;
fp.open("account.dat",ios::in|ios::out);
while(fp.read((char*)&ac,sizeof(account)) && found==0)
{
if(ac.retacno()==no)
{
ac.show_account();
cout<<"\n\n\n----Enter the New Details----\n";
ac.modify_account();
int pos=-1*sizeof(ac);
fp.seekp(pos,ios::cur);
fp.write((char*)&ac,sizeof(account));
cout<<"\n\n\t Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}
//***************************************************************
//
function to delete record of file
//****************************************************************
void delete_account()
{
int no;
cout<<"\n\n====Delete Record====";
cout<<"\n\nEnter The Account No. : ";

cin>>no;
fp.open("account.dat",ios::in|ios::out);
fstream fp2;
fp2.open("Temp.dat",ios::out);
fp.seekg(0,ios::beg);
while(fp.read((char*)&ac,sizeof(account)))
{
if(ac.retacno()!=no)
{
fp2.write((char*)&ac,sizeof(account));
}
}
fp.close();
remove("account.dat");
rename("Temp.dat","account.dat");
cout<<"\n\n\tRecord Deleted ..";
getch();
}
//***************************************************************
//
function to display all accounts deposit list
//****************************************************************
void display_all()
{
fp.open("account.dat",ios::in);
if(!fp)
{
cout<<"ERROR!!! FILE COULD NOT BE OPEN ";
getch();
return;
}
cout<<"\n\n\t\tACCOUNT HOLDER LIST\n\n";
cout<<"====================================================\n";
cout<<"A/c no.\tNAME\t\tType\t\tBalance\n";
cout<<"====================================================\n";
while(fp.read((char*)&ac,sizeof(account)))
{
ac.report();
}
fp.close();
getch();
}
//***************************************************************
//
function to deposit and withdraw amounts
//****************************************************************
void deposit_withdraw(int option)
{
int no,found=0,amt;
cout<<"\n\n====ACCOUNT TRANSCATION FORM====";
cout<<"\n\nEnter The account No. : ";
cin>>no;
fp.open("account.dat",ios::in|ios::out);

while(fp.read((char*)&ac,sizeof(account)) && found==0)


{
if(ac.retacno()==no)
{
ac.show_account();
if(option==1)
{
cout<<"\n\nEnter The amount to DEPOSIT : ";
cin>>amt;
ac.dep(amt);
}
if(option==2)
{
cout<<"\n\nEnter The amount to WITHDRAW : ";
cin>>amt;
int bal=ac.retdeposit()-amt;
if((bal<500 && ac.rettype()=='S') || (bal<1000 && ac.rettype()=='C'))
cout<<"\nInsufficience balance";
else
ac.draw(amt);
}
int pos=-1*sizeof(ac);
fp.seekp(pos,ios::cur);
fp.write((char*)&ac,sizeof(account));
cout<<"\n\n\t Record Updated";
found=1;
}
}
fp.close();
if(found==0)
cout<<"\n\n Record Not Found ";
getch();
}
//***************************************************************
//
INTRODUCTION FUNCTION
//****************************************************************
void intro()
{
clrscr();
textbackground(BLACK);
gotoxy(25,7);
cout<<"==============================";
gotoxy(35,11);
cout<<"BANK";
gotoxy(33,14);
cout<<"MANAGEMENT";
gotoxy(35,17);
cout<<"SYSTEM";
gotoxy(25,21);
cout<<"==============================";
gotoxy(25,24);
cout<<"MADE BY : Administrator";
gotoxy(25,26);
cout<<"SCHOOL : AICS";

getch();
}
//***************************************************************
//
THE MAIN FUNCTION OF PROGRAM
//****************************************************************
void main()
{
char ch;
char pass,ex;
char password[100],passw[100],Userid[100];
int i = 0,counter = 0;
do
{
clrscr();
gotoxy(32,15);
cout<<"Enter username:";
cin>>Userid;
gotoxy(32,18);
cout<<"Enter password:";
cout<<" ";

while (1)
{
pass = getch();
if (pass == 13)
{
break;
}

if(pass == 8)
{
putch('\b');
putch(NULL);
putch('\b');
--i;
continue;
}
if (pass <='9' && pass >= '1' || pass >= 'a' && pass <='z' || pass >='A' && pass <= 'Z')
{
passw[i++] = pass;
cout<<"*";
}
else
continue;
}
cout<<"\n\n";
passw[i]='\0';

if((strcmp)(Userid, "admin") == 0 && strcmp(passw,"admin") ==0 )


{
textcolor(YELLOW+BLINK);
gotoxy(32,22);
cout<<"Login Success!!!!";
gotoxy(32,25);
sound(500);
delay(200);
sound(600);
delay(200);
sound(700);
delay(200);
sound(800);
delay(200);
sound(900);
delay(200);
sound(1000);
delay(200);
nosound();
cout<<"Press any key to continue...";
getch();
goto A;
}
else
{
gotoxy (32,21);
cout<<"Invalid username or password\n";
i = 0;
counter++;
sound(1000);
delay(500);
nosound();
if (counter == 3)
{
clrscr();
gotoxy(32,22);
cout<<"Try again later";
getch();
}
else
{
gotoxy(32,23);
cout<<"Try again [y/n]";
cin>>ex;
}
}
}
while(ex =='y' || ex == 'Y');
exit(0);
A:
intro();
do
{

clrscr();
textcolor(GREEN);
gotoxy(25,2);cputs("\n\n\n\t MAIN MENU :");
gotoxy(25,5);cputs("\n\n\t a. NEW ACCOUNT :");
gotoxy(25,6);cputs("\n\n\t b. DEPOSIT AMOUNT :");
gotoxy(25,7);cputs("\n\n\t c. WITHDRAW AMOUNT :");
gotoxy(25,8);cputs("\n\n\t d. BALANCE ENQUIRY :");
gotoxy(25,9);cputs("\n\n\t e. ALL ACCOUNT HOLDER LIST :");
gotoxy(25,10);cputs("\n\n\t f. CLOSE AN ACCOUNT :");
gotoxy(25,11);cputs("\n\n\t g. MODIFY AN ACCOUNT :");
gotoxy(25,12);cputs("\n\n\t h. EXIT :");
gotoxy(25,13);cputs("\n\n\t Select Your Option (a-h) : ");
ch=getche();
clrscr();
switch(ch)
{
case 'a': write_account();
getch();
break;
case 'b': deposit_withdraw(1);
break;
case 'c': deposit_withdraw(2);
break;
case 'd': display_sp();
break;
case 'e': display_all();
break;
case 'f': delete_account();
break;
case 'g': modify_account();
break;
case 'h': exit;
default : cout<<"\a";
}
}while(ch!='h');
}