Documente Academic
Documente Profesional
Documente Cultură
//
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;
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);
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';
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');
}