computer project

43
COMPUTER PRACTICLE FILE 2001-02

Upload: adarsh-dhawan

Post on 23-Dec-2015

20 views

Category:

Documents


2 download

DESCRIPTION

This is a file for computer project, which is required by boards of CBSE and others for class XII

TRANSCRIPT

Page 1: Computer Project

COMPUTERPRACTICLE FILE

2001-02

BY: - DS: -Akshay Chadha, Mrs. P. Pant.Class XII-B.

Page 2: Computer Project

BANK MANAGEMENT

SYSTEM

Page 3: Computer Project

CONTENTS

1. ACKNOWLEDGEMENT.

2. DECLARATION.

3. CERTIFICATE.

4. PROJECT OVERVIEW.

5. INSTALLATION.

6. DATA DICTIONARY.

7. ERROR MESSAGES.

8. SOURCE CODE.

9. OUTPUT.

10. BIBLIOGRAPHY.

Page 4: Computer Project

ACKNOWLEDGEMENT

I extend my deep gratitude to our respected Computer teacher, Mrs. P. Pant for her able and worthy guidance and suggestion and for providing the required material and facilities that were necessary during the course of completion of this project. I also thank my colleague, Miss Tanvi Hooda for extending her full cooperation for the same.

(Akshay Chadha)

Page 5: Computer Project

DECLARATION

I hereby declare that with the help, guidance and suggestions received by me from our Computer teacher and Head of the Computer Department, Army Public School, Noida, Mrs. P. Pant, this project has been completed. This is my own individual work. It was carried out in the Computer laboratory of Army Public School, Noida in the year 2001-02.

Date :- 2002 Akshay Chadha, XII-A, Army Public School, Noida.

Page 6: Computer Project

CERTIFICATE

This is to certify that Master Akshay Chadha of class XII-B has worked with full determination while doing this project. The work put in by the student is original and an outcome of his own effort. The project work was done under my supervision. This project should be considered for the fulfillment of All India Secondary Board Education examination of class XII for the year 2001-02.

Date:- 2002 Mrs. P. Pant, H.O.D COMPUTER

Army Public School, Noida.

Page 7: Computer Project

PROJECT OVERVIEW

This bank management system is a replica of the software used in banks to manage customer accounts. The software can be accessed only when a valid password in entered. It contains functions for storing and displaying customer details and managing his account effectively. It also displays the various transactions of the account holders. It also provides an overview of the banks past record and future plans.

Page 8: Computer Project

INSTALLATION

The program as well as the software will be stored using normal access methods however the user’s details can only be accessed when a valid password is entered.

Page 9: Computer Project

DATA DICTIONARY

The bank management system employs a wide range of header files, functions, and classes. The purpose of each one of them has been specified below: -

(i) HEADER FILES : -

(a) iostream.h: - It contains various input and output functions.(b) conio.h: - It contains the function clrscr() which is used for clearing the

screen.(c) string.h: - It contains the function strcmp() which compares the alphabets of

two words.(d) stdio.h: - It contains the function printf() which sends the formatted text to the

output screen.(e) dos.h: - It contains the function delay() which delays the output displayed on

the screen for a specific period of time.(f) process.h: - It contains the function exit() which terminates the program.(g) fstream.h: - It contains the stream classes ifstream which is used to read from

a file and ofstream which is used to write to a file.(h) iomaniph,h: - It contains the function setw() which prints the next output after

a specified space.

(ii) FUNCTIONS: -

(a) void about_us: - Displays the historic background of the bank.(b) bank_acc::bank_acc: - Constructor of class bank account for initializing

the user’s balance to zero.(c) void trans::disp(): - function of class trans to display transaction headings.(d) int match(long intacno, char pw [10]):- Compares the password and

account number entered by the user.(e) clrscr(): -Clears the screen.(f) void trans::show_trans: -Function of class trans to display transactions of

various account holders.(g) void bank_acc::ba getdata(): -Function of class bank account to get user’s

details.(h) void bank_acc::ba_showdata(): - Function of class bank account to display

user’s details.(i) void bank_acc::ba_deposit(): - Function of class bank account for

depositing money by the user.(j) void bank_acc::ba_withdraw(): - Function of class bank account for

withdrawing money by the user.

Page 10: Computer Project

(k) void bank_acc::ba_showall(): - Function of class bank account for withdrawing money by the user.

(l) int match_pass(char pw[10]): - Function for matching the password of the user with the already existing password.

(m) int match(long int acno,char pw[10]): - Function to comparethe account number and password entered by the user.

(n) void main_screen(): - Function for bthe main screen.(o) void set_screen(): - Function to display how to enter his or her choice.(p) void menu1(): - Function for the main menu which shows various options

for the user.(q) bk.ba_getdata(): - Function to get user details.(r) void close_acc() : - Function for closing an existing account.(s) void menu2(): - Function for displaying the menu after the user has logged

on.(t) void login(): - Function to take in user’s account number and password

and login in order to withdraw, deposit, close and carry out other operations.

(iii) CLASSES: -

(a) class bank_acc: - Class to hold the details of a user opening an account in the bank.

(b) class trans: - Class to hold the details of the user’s transactions.

Page 11: Computer Project

ERROR MESSAGES

(a) When the wrong password is entered, the computer denies the access.

(b) When there are no transactions or there is no account holder, the computer displays a message, “no transaction exists” or “no account exists”.

Page 12: Computer Project

SOURCE CODE

#include<iostream.h>#include<conio.h>#include<string.h>#include<stdio.h>#include<dos.h>#include<process.h>#include<fstream.h>#include <iomanip.h>

//FUNCTION FOR DISPLAYING THE HISTORIC BACKGROUND OF THE BANKvoid about_us(){

cout<<"\n\n\n\t\t\t\tABOUT US:- \n\n\n ";cout<<"\t\tThe bank was established in the year 1996.\

n";cout<<"\t\tFrom then on the bank has grown & has

branches \n";cout<<"\t\tin many big cities of the country.The bank

has \n";cout<<"\t\tmore than 1000 account holders & has served

many \n";cout<<"\t\tmore before them.We assure you that choosing

this \n";cout<<"\t\tbank will definitely benifit you in every

respect.\n";cout<<"\n\n\t\t\t\t\t\tTHANK YOU.";

}

//INTEGER VARIABLE TO CHECK CONDITION FOR ANY USER'S LOGGING INint log = 0;

//INTEGER VARIABLE TO GET THE VALUE OF THE GET & PUT POINTERlong n;

//STRUCTURE FOR:-//DATE OF BIRTH OF USER AND

Page 13: Computer Project

//DATE OF VARIOUS TRANSACTIONSstruct ddate{

int day;int month;int year;

};//END OF STRUCTURE DECLARATION

//OBJECT OF TYPE FSTREAM FOR BOTH WRITING & READING FROM FILEfstream ifile1;

//STRUCTURE FOR THE ADDRESS OF USERstruct address{

int hno;int secno;char city [20];

};//END OF STRUCTURE DECLARATION

//CLASS TO HOLD THE VARIOUS DETAILS OF USER//OPENING AN ACCOUNT IN THE BANKclass bank_acc{

public ://CHARACTER TYPE TO HOLD NAME OF USERchar username [20];//DDATE TYPE TO HOLD THE DATE OF BIRTH OF USERddate userdob;//ADDRESS TYPE TO HOLD THE ADDRESS OF USERaddress a;//CHARACTER TYPE TO HOLD PASSWORD OF USER'S

ACCOUNTchar pass [10];//INTEGER TYPE TO HOLD THE USER'S ACCOUNT NUMBERlong int acc_no;//INTEGER TYPE TO HOLD THE USER'S BALANCElong int balance;//INTEGER TYPE TO HOLD THE AMOUNT TO BE WITHDRAWNlong int wm;//INTEGER TYPE TO HOLD THE AMOUNT TO BE DEPOSITEDlong int dm;//CHARACTER TYPE TO HOLD THE USER'S ACCOUNT TYPEchar acc_type;//PROTOTYPE OF THE CONSTRUCTOR FUNCTIONbank_acc();//PROTOTYPE OF FUNCTION TO GET USER'S DETAILS

Page 14: Computer Project

void ba_getdata();//PROTOTYPE OF FUNCTION TO DISPLAY USER'S DETAILSvoid ba_showdata();//PROTOTYPE OF FUNCTION FOR DEPOSITING IN USER'S

ACCOUNTvoid ba_deposit();//PROTOTYPE OF FUNCTION FOR WITHDRAWING FROM

USER'S ACCOUNTvoid ba_withdraw();//PROTOTYPE OF FUNCTION FOR DISPLAYING ALL

ACCOUNTSvoid ba_showall();

};//END OF CLASS DECLARATION

//CONSTRUCTOR OF CLASS BANK ACCOUNT//FOR INITIALISING THE BALANCE OF USER TO ZERObank_acc::bank_acc(){

balance = 0;}//OBJECT OF CLASS BANK ACCOUNT//FOR ASSIGNING DETAILS OF CURRENT USER//TO DEPOSIT & WITHDRAW MONEYbank_acc curuser;

//CLASS TO HOLD THE VARIOUS DETAILS OF USER'S TRANSACTIONSclass trans{

public://DDATE TYPE TO HOLD THE DATE OF TRANSACTIONddate dot;//CHARACTER TYPE TO HOLD THE TYPE OF TRANSACTIONchar type_trans [20];//INTEGER TYPE TO HOLD THE USER'S ACCOUNT NUMBERlong acno;//INTEGER TYPE TO HOLD//THE AMOUNT BEING DEPOSITED OR WITHDRAWNlong int amount;//PROTOTYPE OF FUNCTION//FOR DISPLAYING THE TRANSACTION HEADINGSvoid disp();//PROTOTYPE OF FUNCTION//FOR DISPLAYING THE TRANSACTIONS OF VARIOUS USERSvoid show_trans();

};//END OF CLASS DECLARATION

//FUNCTION OF CLASS TRANS TO DISPLAY TRANSACTION HEADINGS

Page 15: Computer Project

void trans::disp(){

//CLEARING SCREEN FOR NEW OUTPUTclrscr();//OBJECT OF CLASS TRANStrans t;//OPENING FILE:-TRANS.TXT//DECLARING OBJECT OF CLASS IFSTREAM TO READ FROM FILEifstream ifile( "TRANS.TXT" , ios::binary );//CHECKING WHETHER FILE EXISTS OR NOTif(!ifile){

gotoxy(30,10);cout<<"NO TRANSACTIONS EXIST";

}else{

//OUTPUTcout<<"DATE OF TRANSACTION";cout<<"\t ACCOUNT NO";cout<<"\tTYPE OF TRANSACTION";cout<<"\tAMOUNT";//READING OBJECTS FROM FILEifile.read(( char * ) & t , sizeof (t));while( !ifile.eof() )//CONDITION FOR END OF FILE{

t.show_trans();//FUNCTION CALL//READING OBJECT OF CLASS TRANS FROM FILEifile.read(( char * ) & t,sizeof (t));

}}//END ELSEifile.close();//CLOSING FILE

}//END OF FUNCTION DEFINITION

//FUNCTION OF CLASS TRANS TO DISPLAY TRANSACTIONS OF VARIOUS ACCOUNT HOLDERSvoid trans::show_trans(){

cout<<"\n";//DISPLAYING THE DATE OF TRANSACTIONcout<<setw(2)<<dot.day;cout<<"/"<<setw(2)<<dot.month;cout<<"/"<<setw(2)<<dot.year;//DISPLAYING THE ACCOUNT NO OF USERcout<<setw(20)<<acno;//DISPLAYING THE TYPE OF TRANSACTIONcout<<setw(20)<<type_trans;

Page 16: Computer Project

//DISPLAYING THE TRANSACTION AMOUNTcout<<setw(20)<<amount;

}//END OF FUNCTION DEFINITION

void login();//FUNCTION PROTOTYPE

void menu1();//FUNCTION PROTOTYPE

int match_pass(char pw[10]);//FUNCTION PROTOTYPE

//FUNCTION OF CLASS BANK ACCOUNT TO GET USER'S DETAILSvoid bank_acc::ba_getdata(){

//INITIALISING THE BALANCE TO ZERObalance = 0;//ASKING FOR USER'S NAMEcout<<"\n\t\tENTER USER NAME\n\t\t";//TAKING IN USER'S NAMEcin.getline(username,20);//FOR TAKING IN THE PASSWORDchar pw[10];//ARRAY OF CHARACTERS TO HOLD THE USER'S

PASSWORDint ch;//LOOP FOR TAKING IN PASSWORDdo{

int i = 0;//INITIALISING i=0cout<<"\n\t\tENTER THE PASSWORD\n\t\t";while(ch!= 13){

//TAKING IN THE CHARACTER ENTERED INTO VARIABLE CH

ch = getch();//PUTTING THE '*' CHARACTER ON THE SCREENputch('*');//ASSIGNING CH'S VALUE TO PASSpass[i] = ch;//INCREMENTING VALUE OF ii++;

}//END WHILE LOOPi = i-1;//DECREEMENTING i BY 1pass[i] = '\0';//TERMINATING THE STRING BY PUTTING

'/0'}while(match_pass(pass)!= 1);//CONDITION FOR LOOP TO

CONTINUE//ASKING FOR USER'S DATE OF BIRTH

Page 17: Computer Project

cout<<"\n\t\tENTER DATE OF BIRTH:- DD MM YY\n\t\t(PLEASE GIVE SPACE AFTER EACH ENTRY)\n\t\t";

//TAKING IN USER'S DATE OF BIRTHcin>>userdob.day>>userdob.month>>userdob.year;//ASKING FOR USER'S ADDRESScout<<"\n\t\tENTER YOUR ADDRESS:-HNO SEC CITY\n";cout<<"\t\t(PLEASE GIVE SPACE AFTER EACH ENTRY)\n\t\t";//TAKING IN USER'S ADDRESScin>>a.hno>>a.secno>>a.city;//ASKING FOR USER'S ACCOUNT NUMBERcout<<"\n\t\tENTER ACCOUNT NUMBER\n\t\t";cin>>acc_no;//TAKING IN USER'S ACCOUNT NUMBER//ASKING FOR USER'S ACCOUNT TYPEcout<<"\n\t\tENTER TYPE OF ACCOUNT:-(S-SAVINGS/C-

CURRENT)\n\t\t";cin>>acc_type;//TAKING IN USER'S ACCOUNT TYPE

}

//FUNCTION OF CLASS BANK ACCOUNT TO DISPLAY USER'S DETAILSvoid bank_acc::ba_showdata(){

//CLEARING THE SCREEN FOR NEW OUTPUTclrscr();//DISPLAYING USER'S DETAILScout<<"\n\n\t\tNAME:-\n\t\t"<< username;cout<<"\n\n\t\tDATE OF BIRTH:-\n\t\t";cout<<userdob.day<<"/";cout<<userdob.month<<"/";cout<<userdob.year;cout<<"\n\n\t\tADDRESS OF USER:-\n\t\t";cout<<a.hno<<",";cout<<a.secno<<",";cout<<a.city;cout<<"\n\n\t\tUSER'S ACCOUNT NUMBER IS:-\n\t\t";cout<<acc_no<<"\n";cout<<"\n\t\tUSER'S BALANCE:-\n\t\t";cout<<balance<<" \n";cout<<"\n\t\tUSER'S ACCOUNT TYPE:-\n\t\t";if(acc_type=='s'||acc_type=='S'){

cout<<"SAVINGS\n";}else{

cout<<"CURRENT\n";}

}//END OF FUNCTION DEFINITION

Page 18: Computer Project

//FUNCTION OF CLASS BANK ACCOUNT FOR DEPOSITING MONEY BY THE USERvoid bank_acc::ba_deposit(){

clrscr();//OBJECT OF CLASS OFSTREAM TO WRITE THE TRANSACTIONS TO

FILE//OPENING FILE IN BINARY & APPEND MODEofstream ofile("TRANS.TXT",ios::binary|ios::app);//OBJECT OF CLASS TRANStrans t;//ASSIGNING THE TRANSACTION TYPE TO OBJECT OF CLASS

TRANSstrcpy(t.type_trans,"DEPOSIT");//ASSIGNING THE ACCOUNT NUMBER TO OBJECT OF CLASS TRANSt.acno = curuser.acc_no;cout<<"\n\n\t\t\tENTER DATE OF DEPOSITING dd mm yy\n";cout<<"\t\t\t(PLEASE GIVE SPACE AFTER EACH ENTRY)\n\t\

t\t";//ASSIGNING THE DATE OF TRANSACTION TO OBJECT OF CLASS

TRANS//ASSIGNING THE ACCOUNT NUMBER TO OBJECT OF CLASS TRANScin>>t.dot.day>>t.dot.month>>t.dot.year;//VARIOUS CONDITIONS FOR DEPOSITION OF MONEYif(balance==0){

cout<<"\n\t\t\tYOU HAVE AN EMPTY ACCOUNT\n";cout<<"\n\t\t\tMINIMUM AMOUNT SHOULD BE MORE THAN

Rs1000\n";cout<<"\n\t\t\tENTER THE AMOUNT\n\t\t\t";cin>>dm;//ASSIGNING THE AMOUNT OF TRANSACTION//TO OBJECT OF CLASS TRANSt.amount = dm;balance = balance+dm;

}else{

cout<<"\n\t\t\tENTER THE AMOUNT\n\t\t\t";cin>>dm;//ASSIGNING THE AMOUNT OF TRANSACTION//TO OBJECT OF CLASS TRANSt.amount = dm;balance = balance+dm;

}//WRITING OBJECT OF CLASS TRANS TO FILEofile.write((char*)&t,sizeof(t));

Page 19: Computer Project

ofile.flush();ofile.close();//CLOSING THE FILE

}//END OF FUNCTION DEFINITION

//FUNCTION OF CLASS BANK ACCOUNT FOR WITHDRAWING MONEY BY THE USERvoid bank_acc::ba_withdraw(){

//CLEARING THE SCREENclrscr();//OBJECT OF CLASS TRANStrans t;//ASSIGNING THE TRANSACTION TYPE TO OBJECT OF CLASS

TRANSstrcpy(t.type_trans,"WITHDRAWL");//ASSIGNING THE ACCOUNT NUMBER TO OBJECT OF CLASS TRANSt.acno = curuser.acc_no;cout<<"\n\n\t\t\tENTER DATE OF WITHDRAWING dd mm yy\n";cout<<"\t\t\t(PLEASE GIVE SPACE AFTER EACH ENTRY)\n\t\

t\t";

//ASSIGNING THE ACCOUNT NUMBER TO OBJECT OF CLASS TRANScin>>t.dot.day>>t.dot.month>>t.dot.year;//VARIOUS CONDITIONS FOR WITHDRAWL OF MONEYif(balance==0){

cout<<"\n\t\t\tYOU DO NOT HAVE ANY MONEY IN YOUR ACCOUNT \n";

cout<<"\n\t\t\tYOU WILL HAVE TO DEPOSIT FIRST\n";}if(balance<1000){

cout<<"\n\t\t\tYOU DO NOT HAVE ADEQUATE MONEY IN YOUR ACCOUNT\n";

cout<<"\n\t\t\tYOU WON'T BE ABLE TO WITHDRAW ANY MONEY\n";

}if((balance>0)&&(balance>1000)){

cout<<"\n\t\t\tENTER MONEY TO BE WITHDRAWN\n\t\t\t";

cin>>wm;if(wm>balance){

cout<<"\n\t\t\tYOU HAVE REQUESTED TO WITHDRAW MORE MONEY\n";

Page 20: Computer Project

cout<<"\n\t\t\tTHAN YOU HAVE IN YOUR ACCOUNT\n";

cout<<"\n\t\t\tPLEASE WITHDRAW AGAIN\n";}else{

//OBJECT OF CLASS OFSTREAM TO WRITE THE TRANSACTIONS TO FILE

//OPENING FILE IN BINARY & APPEND MODEofstream ofile("TRANS.TXT",ios::binary|

ios::app);//ASSIGNING THE AMOUNT OF TRANSACTION//TO OBJECT OF CLASS TRANSt.amount = wm;//WRITING OBJECT OF CLASS TRANS TO FILEofile.write((char*)&t,sizeof(t));ofile.flush();//CLOSING THE FILEofile.close();balance = balance-wm;

}}

}//END OF FUNCTION DEFINITION

//FUNCTION OF CLASS BANK ACCOUNT FOR WITHDRAWING MONEY BY THE USERvoid bank_acc::ba_showall(){

//CLEARING THE SCREENclrscr();//DECLARATION OF AN OBJECT OF CLASS BANK ACCOUNTbank_acc ba;//DECLARATION OF AN OBJECT OF CLASS IFSTREAM FOR

READING FROM FILE//OPENING FILE IN BINARY MODEifstream ifile("PROJECT.TXT",ios::binary);//CHECKING WHETHER FILE EXISTS OR NOTif(!ifile){

gotoxy(30,10);cout<<"NO ACCOUNTS EXIST";

}else{

//READING FROM FILEifile.read((char*)&ba,sizeof(ba));while(!ifile.eof())//CONDITION FOR END OF FILE

Page 21: Computer Project

{//CALLING SHOWDATA TO DISPLAY USER DETAILSba.ba_showdata();getch();//READING NEW RECORD FROM FILEifile.read((char*)&ba,sizeof(ba));

}}//END ELSEifile.close();//CLOSING THE FILE

}

//FUNCTION FOR MATCHING THE PASSWORD OF NEW USER//WITH AN ALREADY EXISTING PASSWORDint match_pass(char pw[10]){

//OBJECT OF CLASS BANK ACCOUNTbank_acc b_a;//OBJECT OF CLASS IFSTREAM TO READ FROM FILEifstream ifile("PROJECT.TXT",ios::binary);while(!ifile.eof())//CONDITION FOR END OF FILE{

//READING OBJECT FROM FILEifile.read((char*)&b_a,sizeof(b_a));//COMPARING NEW & OLD PASSWORDSif(strcmp(b_a.pass,pw)==0){

return 0;}

}ifile.close();//CLOSING FILEreturn 1;

}

//FUNCTION TO COMPARE THE ACCOUNT NO & PASSWORD ENTERED BY USERint match(long int acno,char pw[10]){

//CLEARING THE SCREENclrscr();//OBJECT OF CLASS BANK ACCOUNTbank_acc b_a;//OPENING FILE BY GLOBAL OBJECT OF CLASS FSTREAMifile1.open("PROJECT.TXT", ios::nocreate|ios::in|

ios::out|ios::binary);//INITIALISING j=0int j = 0;//READING OBJECT FROM FILE

Page 22: Computer Project

ifile1.read((char*)&b_a,sizeof(b_a));while(!ifile1.eof())//CONDITION FOR END OF FILE{

//COMPARING ACCOUNT NO & PASSWORD ENTERED BY USER//WITH EXSTING ACCOUNT NUMBERS & PASSWORDSif((b_a.acc_no==acno)&&(strcmp(b_a.pass,pw)==0)){

//ASSIGNING THE USER WHEN FOUND//TO GLOBAL OBJECT curusercuruser = b_a;//CLEARING THE SCREENclrscr();gotoxy(30,12);cout<<"PLEASE PROCEED";//ASSIGNING LOG THE VALUE 1log = 1;//GETTING THE RECORD POINTER'S VALUE IN nn = ifile1.tellg() - sizeof(b_a);//ifile1.close();getch();j = 1;return 1;

}//READING NEW RECORD FROM FILEifile1.read((char*)&b_a,sizeof(b_a));

}

ifile1.close();//CLOSING THE FILEif(j==0){

clrscr();gotoxy(30,15);cout<<"ACCESS DENIED";//ASSIGNING LOG THE VALUE 0log = 0;sound(2000);delay(1500);nosound();return -1;

}}//END OF FUNCTION DEFINITION

//FUNCTION FOR THE MAIN SCREENvoid main_screen(){

clrscr();textcolor(2);//ASSIGNING TEXT A COLOUR

Page 23: Computer Project

textbackground(1);//ASSIGNING TEXTBACKGROUND A COLOURclrscr();gotoxy(30,5);cprintf("WELCOME TO OUR BANK");delay(2000);menu1();//CALLING FUNCTION FOR VARIOUS CHOICES//getch();

}

//FUNCTION FOR DISPLAYING HOW TO ENTER HIS/HER CHOICEvoid set_screen(){

//textbackground(1);//ASSIGNING TEXTBACKGROUND A COLOURcout<<"\n\n\t\tPRESS 1.LOGIN";cout<<" 2.NEW ACCOUNT";cout<<" 3.ABOUT US\n\t";cout<<" 4.VIEWING ALL ACCOUNTS";cout<<" 5.VIEWING ALL TRANSACTIONS";cout<<" 6.EXIT";

}

//FUNCTION FOR THE MAIN MENU SCREEN FOR VARIOUS OPTIONS FOR THE USERvoid menu1(){

clrscr();//OBJECT OF CLASS BANK ACCOUNTbank_acc bk;//OBJECT OF CLASS TRANSACTIONtrans t;char ch;//CHARACTER TO TAKE IN CHOICE ENTERED BY USER//LOOP FOR DISPLAYING HE VARIOUS OPTIONS TILL EXIT IS

PRESSEDwhile(1){

clrscr();gotoxy(30,5);cout<<"1) LOGIN ";gotoxy(30,7);cout<<"2) NEW USER ";gotoxy(30,9);cout<<"3) ABOUT US ";gotoxy(30,11);cout<<"4) VIEW ALL ACCOUNTS ";gotoxy(30,13);cout<<"5) VIEW ALL TRANSACTIONS ";gotoxy(30,15);

Page 24: Computer Project

cout<<"6) EXIT ";gotoxy(30,17);cout<<"ENTER YOUR CHOICE\n";set_screen();//FUNCTION CALLch = getch();//TAKING N CHOICE//VARIOUS CASES MATCHING THE CHOICESswitch(ch){

case'1':clrscr();login();//CALLING THE FUNCTION TO LOG INgetch();break;

case'2':clrscr();//OPENING FILE TO WRITEofstream

ofile("PROJECT.TXT",ios::binary|ios::app);char ch1;cin.get(ch1);//FUNCTION TO GET USER DETAILSbk.ba_getdata();//WRITING THE OBJECT TO FILEofile.write((char*)&bk,sizeof(bk));ofile.flush();//CLOSING THE FILEofile.close();break;

case'3':clrscr();//FUNCTION CALL TO DISPLAY DATA ABOUT

THE BANKabout_us();getch();break;

case'4'://FUNCTION CALL TO DISPLAY//DETAILS OF ALL ACCOUNT HOLDERSbk.ba_showall();break;

case'5'://FUCTION CALL TO DISPLAY//ALL TRANSACTIONSt.disp();getch();break;

case'6':

Page 25: Computer Project

clrscr();gotoxy(30,10);cout<<"THANK YOU FOR YOUR TIME";delay(2000);exit(0);break;

}//END SWITCH STATEMENT

} //END WHILE LOOPgetch();

}//END OF FUNCTION DECLARATION

//FUNCTION FOR CLOSING AN EXISTING ACCOUNTvoid close_acc(){

cout<<"CLOSING ACCOUNT";//OBJECT OF CLASS BANK ACCOUNTbank_acc b;//INITIALISING COUNTER VARIABLE TO 1int count = 1;//CLOSING FILE-PROJECT USING GLOBAL VARIABLEifile1.close();//CALCULATNG RECORD NUMBER TO BE DELETEDint recno = ( n/sizeof(bank_acc)) + 1;getch();//OPENING THE FILE-PROJECT IN INPUT & BINARY MODEifile1.open ("PROJECT.TXT",ios::in|ios::binary);//OPENING A TEMPORARY FILE IN OUTPUT & BINARY MODEofstream outfile ("TEMP.TXT", ios::out|ios::binary);//READING AN OBJECT FROM FILE-PROJECTifile1.read((char *) & b, sizeof(b));while (!ifile1.eof())//CONDITION FOR END OF FILE{

//CHECKING FOR RECORD TO BE DELETEDif (count != recno){

//WRITING OBJECT NOT TO BE DELETED TO TEMPORARY FILE

outfile.write((char *) &b, sizeof(b));outfile.flush();

}//REAING NEXT RECORD FROM FILE-PROJECTifile1.read((char *) & b, sizeof(b));//INCREMENTING THE RECORD COUNTERcount ++;

}//END OF WHILE LOOPifile1.close();//CLOSING FILE-PROJECT.TXT

Page 26: Computer Project

outfile.close();//CLOSING FILE-TEMP .TXTremove("PROJECT.TXT");//REMOVING THE OLD FILE//RENAMING THE TEMPORARY FILE AS PROJECT.TXTrename("TEMP.TXT", "PROJECT.TXT");getch();

}//END OF FUNCTION DECLARATION

//FUNCTION DISPLAYING THE MENU AFTER USER LOGS INvoid menu2(bank_acc bk){

clrscr();char ch;//CHARACTER TO TAKE IN CHOICE OF USER//LOOP GIVING THE VARIOUS CHOICESwhile(1){

clrscr();gotoxy(30,5);cout<<"WHAT WOULD YOU LIKE TO DO?";gotoxy(30,8);cout<<"1) DEPOSIT MONEY";gotoxy(30,11);cout<<"2) WITHDRAW MONEY";gotoxy(30,14);cout<<"3) CLOSE ACCOUNT";gotoxy(30,17);cout<<"4) DISPLAY USER DATA";gotoxy(30,20);cout<<"5) RETURN TO MAIN MENU";gotoxy(30,23);cout<<"ENTER YOUR CHOICE";ch = getch();//CHECKING VARIOUS CASESswitch(ch){

case'1'://FUNCTION CALL TO DEPOSIT MONEYbk.ba_deposit();//OPENING FILE-PROJECT//IN INPUT & BINARY MODEifstream ifile("PROJECT.TXT", ios::in|

ios::binary);//MOVING FILE POINTER TO AN ABSOLUTE

POSITION//AS RETURNED BY TELLGifile1.seekp(n);//WRITING NEWLY ENTERED INFO TO OBJECT

Page 27: Computer Project

ifile1.write((char *) &bk, sizeof(bk));ifile1.flush();//getch();break;

case'2'://FUNCTION CALL TO WITHDRAW MONEYbk.ba_withdraw();//OPENING FILE-PROJECT//IN INPUT & BINARY MODEifstream file("PROJECT.TXT", ios::in|

ios::binary);//MOVING FILE POINTER TO AN ABSOLUTE

POSITION//AS RETURNED BY TELLGifile1.seekp(n);//WRITING NEWLY ENTERED INFO TO OBJECTifile1.write((char *) &bk, sizeof(bk));ifile1.flush();//getch();break;

case'3'://FUNCTION CALL TO CLOSE USER'S ACCOUNTclose_acc();//ASSIGNING LOG THE VALUE ZEROlog = 0;//getch();return;

case'4'://FUNCTION CALL TO DISPLAY USER'S

DETAILSbk.ba_showdata();getch();break;

case'5'://ASSIGNING LOG THE VALUE ZEROlog = 0;ifile1.close();return;

}//END OF SWITCH STATEMENT}//END WHILE LOOPgetch();

}//END OF FUNCTION DECLRATION

//FUNCTION TO TAKE IN USER'S ACCOUNT NO & PASSWORD//& LOGGING IN TO WITHDRAW,DEPOSIT,CLOSE & OTHER OPTIONS FOR USERvoid login()

Page 28: Computer Project

{int ch;int x;//INTEGER VARIABLE TO TAKE IN RETURN VALUE OF

FUNCTION CALLint i = 0;//INITILISING i = 0long int acno;//INTEGER TO TAKE IN ACCOUNT NO OF USERchar pw[10];//CHARACTER ARRAY TO TAKE IN PASSWORDgotoxy(30,10);cout<<"ENTER ACCOUNT NUMBER";cin>>acno;gotoxy(30,15);cout<<"ENTER PASSWORD";//TAKING IN PASSWORDwhile(ch != 13){

ch = getch();putch('*');pw[i] = ch;i++;

}i= i-1;pw[i] = '\0';//TERMINATING THE STRING//CALLING THE FUNCTION TO MATCH BOTH PASSWORD & ACCOUNT

NOx = match(acno,pw);//CHECKING IF LOGIN WAS SUCCESSFULif(x==1){

//CALLING FUNCTION TO DISPLAY//THE MENU FOR VARIOUS CHOICESmenu2(curuser);

}}//END OF FUNCTION CALL

void main(){

clrscr();main_screen();//FUNCTION CALL FOR DISPLAYING THE MAIN

SCREENgetch();

}

OUTPUT

SCREEN 1:- _

Page 29: Computer Project

WELCOME TO OUR BANK

SCREEN 2: -

1) LOGIN

2) NEW USER

3) ABOUT US

4) VIEW ALL ACCOUNTS

5) VIEW ALL TRANSACTIONS

6) EXIT

ENTER YOUR CHOICE

PRESS 1.LOGIN 2.NEW ACCOUNT 3.ABOUT US4.VIEWING ALL ACCOUNTS 5.VIEWING ALL TRANSACTIONS 6.EXIT

SCREEN 3: -ENTER USER NAME

Tanvi Hooda

ENTER THE PASSWORD******

ENTER DATE OF BIRTH:- DD MM YY(PLEASE GIVE SPACE AFTER EACH ENTRY)

19 9 85

ENTER YOUR ADDRESS:-HNO SEC CITY(PLEASE GIVE SPACE AFTER EACH ENTRY)

137 29 noida

ENTER ACCOUNT NUMBER1

ENTER TYPE OF ACCOUNT:-(S-SAVINGS/C-CURRENT)s

SCREEN 4: -

Page 30: Computer Project

ENTER ACCOUNT NUMBER1

ENTER PASSWORD*****

SCREEN 5: -

PLEASE PROCEED

SCREEN 6: -

WHAT WOULD YOU LIKE TO DO?

1) DEPOSIT MONEY

2) WITHDRAW MONEY

3) CLOSE ACCOUNT

4) DISPLAY USER DATA

5) RETURN TO MAIN MENU

ENTER YOUR CHOICE

SCREEN 7: -

ENTER DATE OF DEPOSITING dd mm yy(PLEASE GIVE SPACE AFTER EACH ENTRY)

21 1 02

YOU HAVE AN EMPTY ACCOUNT

MINIMUM AMOUNT SHOULD BE MORE THAN Rs1000

ENTER THE AMOUNT

Page 31: Computer Project

10000

SCREEN 8: -

ENTER DATE OF WITHDRAWING dd mm yy(PLEASE GIVE SPACE AFTER EACH ENTRY)

23 1 02

ENTER MONEY TO BE WITHDRAWN1000

SCREEN 9: -

NAME:-Tanvi Hooda

DATE OF BIRTH:-19/9/85

ADDRESS OF USER:-137,29,noida

USER'S ACCOUNT NUMBER IS:-1

USER'S BALANCE:-9000

USER'S ACCOUNT TYPE:-SAVINGS

SCREEN 10: -

NAME:-Tanvi Hooda

DATE OF BIRTH:-19/9/85

ADDRESS OF USER:-137,29,noida

USER'S ACCOUNT NUMBER IS:-

Page 32: Computer Project

1

USER'S BALANCE:-9000

USER'S ACCOUNT TYPE:-SAVINGS

NAME:-Taruna Hooda

DATE OF BIRTH:-16/11/89

ADDRESS OF USER:-1,37,noida

USER'S ACCOUNT NUMBER IS:-2

USER'S BALANCE:-0

USER'S ACCOUNT TYPE:-CURRENT

SCREEN 11: -

DATE OF TRANSACTION ACCOUNT NO TYPE OF TRANSACTION AMOUNT21/ 1/ 2 1 DEPOSIT

1000023/ 1/ 2 1 WITHDRAWL 1000

21/ 1/ 2 2 DEPOSIT 2000024/ 1/ 2 2 WITHDRAWL 2000

SCREEN 12:-

ENTER ACCOUNT NUMBER3

Page 33: Computer Project

ENTER PASSWORD*

SCREEN 13:-

ACCESS DENIED

SCREEN 14:-

THANK YOU FOR YOUR TIME

SCREEN 15:-

ABOUT US:-

The bank was established in the year 1996.From then on the bank has grown & has branches

in many big cities of the country.The bank hasmore than 1000 account holders & has served manymore before them.We assure you that choosing this

bank will definitely benifit you in every respect.

THANK YOU.

BIBLIOGRAPHY

Computer Science C++ by Mrs. Sumita Arora and Gautam Sarkar.

Page 34: Computer Project

Teacher’s Remarks

Page 35: Computer Project