Mat Khojna

Download as pdf or txt
Download as pdf or txt
You are on page 1of 23

COMPUTER

PROJECT WORK

: DEBSHILPI PATRA
: 12 ‘A2’
: 2019-20
:
: DAV PUBLIC SCHOOL, BISTUPUR
INDEX
S.No. TOPic Page

1. CERTIFICATE 2

2. INTRODUCTION 3

3. MENU TREE 4

4. SYSTEM 5
REQUIREMENTS

5. SOURCE CODE 6 - 18

6. SAMPLE OUTPUT 19-21

7. BIBLIOGRAPHY 22

1
CERTIFICATE
This is to certify that
Master DEBSHILPI PATRA,
AISSCE Roll No have
successfully completed this
project of “ATM”, for the
subject of Computer
Science (OLD), subject code
283 in the academic year
2019-20 under the guidance
of SIR TANMOY PAUL.

EXTERNAL’s SIGNATURE TEACHER’s SIGNATURE

2
INTRODUCTION

This project is a bank program namely,


“ATM”.

It have been designed as a perfect ATM


program in which the customer will
have to create account with initial
deposit amount of minimum Rs.5000/-
and then login. Customer will be
provided 5 option namely deposit,
withdraw, account details, delete
account, log out after log in.

3
MENU TREE

4
SYSTEM REQUIREMENTS
HARDWARE REQUIREMENTS

 PROCESSOR : Pentium III


 RAM : 64 MB
 HARDDISK : 20 GB

SOFTWARE REQUIREMENTS

 OPERATING SYSTEM : Windows 98, XP, Vista, 7, 8, 10


 DOS BOX : 0.74
 TURBO C++ : 3.0

5
SOURCE CODE
#include<fstream.h> //Declares the C++ stream classes that support file input and output.

#include<conio.h> //To use getche(), getch(), clrscr(), gotoxy() function

#include<string.h> //To use strcpy(), strcmp(), function

#include<stdio.h> //To use gets(), remove(), rename() function

#include<stdlib.h> //To use exit() function

#include<dos.h> //To use delay() function

struct prof //Structure to handle profile details of an user

char n[500];

char a[5][500];

double b;

};

class bank //Class containing all functions of atm

char n[200];

void login(); //This function handles everything during log in

void home(); //This function handles the main page after an account is opened

void create(); //This function handles everything while creating account

void deposit(); //This function handles everything during money deposit

void withdraw();//This function handles everything during money withdraw

void detail(); //This function displays an user's account details

void del(); //This function deletes an account

public:

void start(); //This is the first page to ask from user whether to log in, create account or exit

};

6
void bank::start()

repeat:

char a;

clrscr();

cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" 1.LOG IN 2.CREATE ACCOUNT 3.EXIT\n";

cout<<"________________________________________________________________________________\n";

cout<<"\n\nYOUR CHOICE: ";

a=getche();

if(a<'1'||a>'3')

cout<<"\nINVALID INPUT! (PRESS 1/2/3)\n\n\n\n";

cout<<" PRESS ANY KEY!\n";

getch();

goto repeat;

if(a=='1')

login(); //goes to login() function

if(a=='2')

create(); //goes to create() function

if(a=='3')

exit(0); //terminates the program

void bank::login()

prof p;

char zz[500];

clrscr();

7
cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" HELLO I YOUR ATM ASSISTANT WILL BE GUIDING YOU DURING LOG-IN\n";

cout<<"________________________________________________________________________________\n";

cout<<"\n\n";

cout<<"USERNAME : "; gets(n);

ifstream fi("PROFILE.DAT",ios::binary);

while(fi.read((char *)&p,sizeof(p)))

if(!strcmp(n,p.n))

goto z; //if username is available then it goto z to ask for password

cout<<"THE USERNAME DOES NOT EXISTS!\n\n\n\n";

cout<<" PRESS ANY KEY!\n";

getch();

start(); // goes to start if username is not available

z:

cout<<"PASSWORD : ";

char b[1000],c;

int i=0;

while(1) //This loop is an exclusive algorithm to take input of password

b[i]=getche();

c=b[i];

if(b[i]==13)

break;

else if(b[i]==8&&i>=0)

if(i>0)

b[--i]='\0';

gotoxy(i+12,10);

cout<<" ";

8
gotoxy(i+12,10);

i--;

delay(150);

if(c!=8)

gotoxy(12+i++,10);

cout<<"*";

else

gotoxy(13+i++,10);

b[i]='\0';

if(strcmp(b,p.a[4]))

cout<<"\nINCORRECT PASSWORD!\n\n\n\n";

cout<<" PRESS ANY KEY!\n";

getch();

start(); //goes to start() if password is incorrect

fi.close();

home(); //goes to home() and opens the account

void bank::create()

double ab;

char c[500],cc[500];

prof p;

clrscr();

cout<<" ATM\n";

9
cout<<" =======\n\n";

cout<<" HELLO I YOUR ATM ASSISTANT WILL BE GUIDING YOU WHILE CREATING YOUR ACCOUNT\n";

cout<<"________________________________________________________________________________\n";

cout<<endl<<endl;

cout<<"USERNAME : "; gets(n);

ifstream fi("PROFILE.DAT",ios::binary);

while(fi.read((char *)&p,sizeof(p)))

if(!strcmp(n,p.n))

cout<<"THE USERNAME ALREADY EXISTS! TRY SOMETHING ELSE.\n\n\n\n";

cout<<" PRESS ANY KEY!\n";

getch();

start(); //goes to start if username is already available

//takes input of all profile details

strcpy(p.n,n);

cout<<"PASSWORD : "; gets(p.a[4]);

cout<<endl;

cout<<"NAME : "; gets(p.a[0]);

cout<<"ADDRESS : "; gets(p.a[1]);

cout<<"EMAIL ID : "; gets(p.a[2]);

cout<<"PHONE NUMBER : "; gets(p.a[3]);

r:

cout<<"DEPOSIT AMOUNT : "; cin>>ab;

if(ab<5000) //checks for the validity of amount to be deposited during account creation

cout<<"DEPOSIT AT LEAST Rs.5000!\n";

cout<<" PRESS ANY KEY!";

getch();

clrscr();

10
cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" HELLO I YOUR ATM ASSISTANT WILL BE GUIDING YOU WHILE CREATING YOUR ACCOUNT\n";

cout<<"________________________________________________________________________________\n";

cout<<endl<<endl;

//takes input of all profile details if deposited amount was less than 5000

cout<<"USERNAME : "<<n<<endl;

cout<<"PASSWORD : "<<p.a[4]<<endl;

cout<<endl;

cout<<"NAME : "<<p.a[0]<<endl;

cout<<"ADDRESS : "<<p.a[1]<<endl;

cout<<"EMAIL ID : "<<p.a[2]<<endl;

cout<<"PHONE NUMBER : "<<p.a[3]<<endl;

goto r; //goto r to re-deposit amount if amount deposited was less than 5000

p.b=ab;

fi.close();

ofstream fo("PROFILE.DAT",ios::binary|ios::app);

fo.write((char *)&p,sizeof(p));

cout<<"\n\nCONGATULATIONS! YOUR ACCOUNT HAS BEEN SUCCESSFULLY CREATED.\n\n";

cout<<" PRESS ANY KEY!";

getch();

fo.close();

start(); //goes to start page after successfully creating account

void bank::deposit()

prof p;

double z;

11
ifstream fi("PROFILE.DAT",ios::binary);

ofstream fo("temp.dat",ios::binary);

while(fi.read((char *)&p,sizeof(p)))

if(!strcmp(n,p.n))

r:

clrscr();

cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" THIS IS DEPOSIT AMOUNT PAGE\n";

cout<<"_______________________________________________________________________________\n\n\
n";

cout<<"------------------------------------\n";

cout<<"CURRENT BALANCE: Rs."<<p.b<<endl;

cout<<"------------------------------------\n\n";

cout<<"Enter Amount to be deposited: Rs.";

cin>>z;

if(z<0) //checks for the validity of amount deposited

cout<<"INVALID AMOUNT!\n";

cout<<"Enter an ammout equal to or more than Rs.0/-\n";

cout<<" PRESS ANY KEY!";

getch();

goto r; //goto r to re-deposit money

p.b+=z;

cout<<"\n------------------------------------\n";

cout<<"NEW BALANCE: Rs."<<p.b<<endl;

cout<<"------------------------------------\n\n";

12
cout<<"CONGATULATIONS! YOU HAVE SUCCESSFULLY DEPOSITED MONEY INTO YOUR ACCOUNT.\n\n";

cout<<" PRESS ANY KEY!";

getch();

fo.write((char *)&p,sizeof(p));

fo.close();

fi.close();

remove("PROFILE.DAT");

rename("temp.dat","PROFILE.DAT");

home(); //goes to home()

void bank::withdraw()

prof p;

long double z;

ifstream fi("PROFILE.DAT",ios::binary);

ofstream fo("temp.dat",ios::binary);

while(fi.read((char *)&p,sizeof(p)))

if(!strcmp(n,p.n))

r:

clrscr();

cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" THIS IS WITHDRAW AMOUNT PAGE\n";

cout<<"_______________________________________________________________________________\n\n\
n";

cout<<"------------------------------------\n";

13
cout<<"CURRENT BALANCE: Rs."<<p.b<<endl;

cout<<"------------------------------------\n\n";

cout<<"Enter Amount to be withdrawn: Rs.";

cin>>z;

if(z<0) //checks for the validity of amount to be withdrawn

cout<<"INVALID AMOUNT!\n";

cout<<"Enter an amount equal to or more than Rs.0/-\n";

cout<<" PRESS ANY KEY!";

getch();

goto r; //goto r to re-witdraw money

else if(z>p.b-5000) //checks for the validity of amount to be withdrawn

cout<<"INVALID AMOUNT!\n";

cout<<"Enter an amount less than Rs."<<p.b-5000<<"/-\n";

cout<<"Your current balance is Rs."<<p.b<<"/-\n";

cout<<"At least Rs.5000/- should be available always into your account.\n ";

cout<<" PRESS ANY KEY!";

getch();

goto r; //goto r to re-witdraw money

p.b-=z;

cout<<"\n------------------------------------\n";

cout<<"NEW BALANCE: Rs."<<p.b<<endl;

cout<<"------------------------------------\n\n";

cout<<"CONGATULATIONS! YOU HAVE SUCCESSFULLY WITHDRAWN MONEY FROM YOUR ACCOUNT.\n\n";

cout<<" PRESS ANY KEY!";

getch();

14
fo.write((char *)&p,sizeof(p));

fo.close();

fi.close();

remove("PROFILE.DAT");

rename("temp.dat","PROFILE.DAT");

home(); //goes to home()

void bank::detail()

clrscr();

cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" THIS IS YOUR ACCOUNT DETAILS\n";

cout<<"_______________________________________________________________________________\n\n\
n";

prof p;

ifstream fi("PROFILE.DAT",ios::binary);

while(fi.read((char *)&p,sizeof(p)))

if(!strcmp(n,p.n))

//displays user's details

cout<<"USERNAME : "<<p.n<<endl;

cout<<"PASSWORD : "<<p.a[4]<<endl<<endl;

cout<<"NAME : "<<p.a[0]<<endl;

cout<<"ADDRESS : "<<p.a[1]<<endl;

cout<<"EMAIL ID : "<<p.a[2]<<endl;

cout<<"PHONE NUMBER : "<<p.a[3]<<endl;

cout<<"CURRENT BALANCE : "<<p.b<<endl<<endl<<endl;

break;

15
}

cout<<" PRESS ANY KEY!";

getch();

fi.close();

home(); //goes to home()

void bank::del()

char zz;

repeat:

clrscr();

cout<<" ATM\n";

cout<<" =======\n\n";

cout<<" THIS IS DELETE ACCOUNT PAGE\n";

cout<<"_______________________________________________________________________________\n";

cout<<"\n\n";

cout<<" Do you want to delete your account?\n";

cout<<" Y) YES N) NO\n\n";

cout<<" Enter Choice(Y/N): ";

zz=getche();

if(zz=='y'||zz=='Y')

cout<<"\n\n\n\n\n\n ACCOUNT SUCCESSFULLY DELETED\n\n";

cout<<" PRESS ANY KEY!";

getch();

prof p;

ifstream fi("PROFILE.DAT",ios::binary);

ofstream fo("TEMP.DAT",ios::binary);

while(fi.read((char *)&p,sizeof(p)))

16
if(strcmp(n,p.n))

fo.write((char *)&p,sizeof(p));

fi.close();

fo.close();

remove("PROFILE.DAT");

rename("TEMP.DAT","PROFILE.DAT");

start(); //goes to start if account is successfully deleted

else if(zz=='N'||zz=='n')

home(); //goes to home if user do not delete account

else

cout<<"\n\n\n\n\n\n INVALID INPUT! (ENTER Y/N)\n\n";

cout<<" PRESS ANY KEY!";

getch();

goto repeat; //goto repeat if user chooses invalid option

void bank::home()

char a;

while(1)

repeat:

clrscr();

cout<<" ATM\n";

cout<<" =======\n\n";

17
cout<<"1.DEPOSIT 2.WITHDRAW 3.ACCOUNT DETAIL 4.DELETE ACCOUNT 5.LOG OUT\n";

cout<<"_______________________________________________________________________________\n";

cout<<"\n\n";

cout<<"WELCOME SIR/MAM\n";

cout<<"\nCHOOSE ONE OF THE ABOVE FIVE OPTIONS TO PROCEED\n\n\n\n\n\n\n\n\n\n\n";

gotoxy(1,21);

cout<<"_______________________________________________________________________________\n";

cout<<"YOUR CHOICE: ";

a=getche();

switch(a) //Menu driven part of home

case '1': deposit(); break;

case '2': withdraw(); break;

case '3': detail(); break;

case '4': del(); break;

case '5': start(); break;

default: cout<<"\nINVALID INPUT! PRESS ANY KEY!";

getch();

goto repeat; //goto repeat for invalid option

void main()

bank b;

b.start();

18
SAMPLE OUTPUT
PAGE 1:

PAGE 2:

19
PAGE 3:

PAGE 4:

PAGE 5:

20
PAGE 3:

PAGE 4:

PAGE 5:

21
BIBLIOGRAPHY

This project has been successfully


developed with the help of
following accessories:
1) Computer Science with C++
(Sumita Arora)
2) Computer Science with C++
(Arihant Publications)
3) Website: Tutorialspoint

22

You might also like