mini project - atm
TRANSCRIPT
MEPCO SCHLENK ENGINEERING COLLEGE, SIVAKASI
(An Autonomous Institution affiliated to Anna University, Chennai)
DEPARTMENT OF INFORMATION TECHMOLOGY
MINI PROJECT REPORT
13IT351 - OBJECT ORIENTED PROGAMMING USING C++
RAKHAV KRISHNA.G- <201406050>PAVITHRAN.S -<201406044>
KALYANA SUNDAR.G-<201406252>II – IT
1
MEPCO SCHLENK ENGINEERING COLLEGE, SIVAKASI
(An Autonomous Institution affiliated to Anna University, Chennai)VIRUDHUNAGAR DISTRICT, TAMILNADU
DEPARTMENT OF INFORMATION TECHMOLOGY
BONAFIDE CERTIFICATE
This is certify that it is the bonafide work done by RAKHAV KRISHNA.G, PAVITHRAN.S and KALYANA SUNDAR.G for mini project entitled ATM SYSTEM in object oriented programming(cs9) laboratory for the academic year 2015-2016
………………………………….. …………………………..
Mrs.Angela jennifa sujana Dr.Revathi
(Guide) (HOD/IT)
2
TABLE OF CONENTS
S.NO TITLE PAGE NO
1 PROBLEM STATEMENT 5
2
2.1
2.2
2.2.1
2.2.2
2.2.3
2.2.4
2.3
2.3.1
2.3.1.1
2.3.1.2
2.3.1.3
2.3.1.4
2.3.1.5
2.3.1.6
SYSTEM MODEL
LIST OF MODELS
MODULE DESCRIPTION
INSERT
WITHDRAW
BALANCE ENQUIRY
DEPOSIT
CLASS DESCRIPTION
CLASS NOTATIONS
CLASS NAME 1
DATA MEMBER 1
MEMBER FUNCTION 1CLASS NAME 2
DATA MEMBER 2
MEMBER FUNCTION 2
6
6
6
6
6
6
6
7
7
7
7
8
8
8
8
3.
3.1
3.1.1
SYSTEM IMPLEMENTATION
CONCEPT
FILES
9
9
9
3
3.1.2
3.1.3
FRIEND FUNCTION
EXCEPTION HANDLING
10
10
4 CODING 11
5. OUTPUT 18
6. CONCLUSION 24
1.PROBLEM STATEMENT:
4
To write a project for ATM System in oops using C++. It should contain all the basic
transaction that occur in the ATM day to day life. The program must contain ten user accounts.
The user can use our ATM to withdraw money, check balance enquiry and deposit cash to his
account. Implement this using various C++ concepts like inheritance, files, exception handling,
friend function.
2.SYSTEM MODEL:
2.1 LIST OF MODULES: INSERTION WITHDRAW
5
BALANCE ENQUIRY DEPOSIT
2.2 MODULE DESCRIPTION:
2.2.1 INSERT:This function is used to insert the account details into the file. we will store the user name, user
PIN number for 10 user accounts. Then we will read it from the file to check the password for the
respective user.
2.2.2 WITHDRAW:
This function is used to withdraw the cash form the account. In this function we get the
amount to withdraw from the user account. Then we will deduce the withdrawn amount from the
balance of the account and current balance is shown. If anyone enter random value which is
other than multiples of 10 then it will deliver the message that the user should enter the
withdrawal amount in multiples of 10.
2.2.3 BALANCE ENQUIRY:
This function is used to display the balance in a account. In this function we will print the
user account number and account balance.
2.2.4 DEPOSIT:
This function is used to deposit cash in user account. In this function we will ask the
amount to be deposited. Then the amount will be credited in the account and the current balance is
shown.
2.3 CLASS DESCRIPTION:
2.3.1 CLASS NOTATIONS:
6
user
string nameint pin
User(string,int)Printdetails()
Friend int finding(user,user,int)
atm
int accntnoint balance
Void readdetails()Void checkbalance(int)Void withdrawcash()Void depositcash()
2.3.1.1 CLASS NAME 1:
user
2.3.1.2 DATA MEMBER 1:
name : It is used to store the name of the user
pin : It is used to store the pin number of the account
2.3.1.3 MEMBER FUNCTION 1:
User(string,int): It is a parameterized constructor
printdetails() : It is used to print account holder name and password “*”
Friend finding : It is used to check the user name and password
7
2.3.1.4 CLASS NAME 2:
atm
2.3.1.5 DATA MEMBER 2:
accntno : It is used to represent the account number
balance : It is used to represent the balance
2.3.1.6 MEMBER FUNCTION 2:
Readdetails() : It is used to read the account details
Checkbalance() : It is used to check
withdrawcash() : It is used to debit cost from the balance
depositcash() : It is used to credit cost to the balance
3.SYSTEM IMPLEMENTATION
3.1 CONCEPT:
FILES
8
FRIEND FUNCTION
EXCEPTION HANDLING
3.1.1 FILES
File handling is the unique identification to describe the file. It is an index to the
array where the file related information is stored. One will be able to manipulate the content of
that file with such a file object handle ,which in our case, we will not directly operating.
To open a text file : ofstream object(“filename”);
Eg: ofstream entryfile(“linear.dat”);
To read a text file : ifstream object(“filename”);
Eg: ifstream disfile(“linear.dat”);
To open binary file : ofstream object(“filename”,modes);
To close binary file : filename.close();
The reading and writing operation in binary files are
Ofstream object.write((datatype *)&<the object>,sizeof(<the object>));
Eg: Ofstream outfile.write((char *) &b, sizeof(student));
Ifstream object.read((datatype *)&<the object>,sizeof(<the object>));
Eg: Ifstream outfile.read((char *) &b, sizeof(student));
3.1.2 FRIEND FUNCTION:
9
Friend function can access private data members of class. The friend function are special
function. The class grants these function a special privilege to access it private variables.the
privilege must be give by the class itself.
SYNTAX:
Friend somefunction(list of argument);
EXAMPLE:
Friend display(person t);
3.1.3 EXCEPTION HANDLING
Exception handling is a method to reduce to error on input time. When exception
handling is in place, instead of providing normal means of execution when an exception occurs,
an alternative path of execution need to be provided. Exception handling is a mechanism to
generate and handle exceptions. In exception has three block
Try
Catch
Throw
3.1.3.1 TRY:
It indicates the program area where exception may arise or may be thrown
3.1.3.2 CATCH:
It is used to take an action path inspecific exception
3.1.3.3 THROW
It is used to throw exception
10
4.CODING:
/*PROGRAM NAME: ATM system
PURPOSE: To maintain the bank account*/
#include<iostream>
#include<fstream>
#include<string>
#include<cstdio>
#include<exception>
#include<stdlib.h>
using namespace std;
class user
{
public:
string name;
int pin;
user(string tname="",int tpin='0')
{
name=tname;
pin=tpin;
}
void printdetails()
{
cout<<"\nAccount Holder Name is "<<name;
cout<<"\nPassword is ****";
11
}
friend int finding(user u[10],user b,int n);
};
class atm:public user
{
public:
int accntno;
int balance;
void readdetails()
{
cout<<"\nEnter the Account Number";
cin>>accntno;
cout<<"\nEnter the Balance Initially";
cin>>balance;
}
void checkbalance(int e)
{
user u[10];
cout<<"\nBalance in the Account is "<<balance;
cout<<"\nAccount Number of Yours is"<<accntno;
}
void withdrawcash()
{
int withdraw;
cout<<"\nEnter the amount to be withdrawn";
12
cin>>withdraw;
if(withdraw%100!=0)
cout<<"\nPlease Enter the amount to be withdrawn in multiples of 100";
else if(withdraw>balance)
cout<<"\nInsufficient Balance in your account";
else
{
balance=balance-withdraw;
cout<<"\nPlease collect the cash";
cout<<"\nYour Current Balance is "<<balance;
}
}
void depositcash()
{
int deposit;
cout<<"\nEnter the Amount To be Deposited";
cin>>deposit;
balance=balance+deposit;
cout<<"\nYour Current Balance is "<<balance;
}
};
int finding(user u[10],user b,int n)
{
int i;
for(i=0;i<n;i++)
13
{
if(u[i].name==b.name && u[i].pin==b.pin)
{
return i;
break;
}
}
return -1;
}
int menu()
{
int i;
cout<<"\n\t\tWelcome to RAPASU ATM\t\t";
cout<<"\nEnter Your Choice\n\t1.Check Balance \n\t2.Withdraw Cash\n\t3.Deposit Cash \n\t4.To exit and to switch to other user\n\t5.To Exit Totally";
cin>>i;
return i;
}
main()
{
fstream file1("details.txt",ios::in|ios::out|ios::binary|ios::trunc);
int i,tpin,k=0,e,d,r=0;
int n=10;
char s;
atm c[10];
14
string na;
int j[10];
for(i=0;i<10;i++)
{
j[i]=0;
}
user u[10]={
user("Rakhav",1234),user("Krishna",1235),user("Keshav",1236),user("Hari",1237),user("Riya",1238),user("Pavithran",1239),user("Sundhar",1240),user("Balan",1241),user("Karthik",1242),user("Vignesh",1243)};
user a[10];
for(i=0;i<10;i++)
{
file1.write((char *) &u[i],sizeof(user));
}
for(i=0;i<10;i++)
{
file1.seekg(i*sizeof(user),ios::beg);
file1.read((char *) &a[i],sizeof(user));
}
for(i=0;i<10;i++)
{
a[i].printdetails();
}
Rakhav:
15
cout<<"\nEnter the UserName";
cin>>na;
cout<<"\nEnter the pin";
cin>>tpin;
user b(na,tpin);
k=finding(a,b,n);
e=k;
try
{
if(k==-1)
throw 21;
}
catch(int)
{
cout<<"\nINVALID PASSWORD";
exit(0);
}
if(j[e]==0)
{
c[e].readdetails();
j[e]=j[e]+1;
}
do
{
loop: d=menu();
16
switch(d)
{
case 1:
cout<<"\nAccount Holder Name is "<<na;
cout<<"\nPassword is ****";
c[k].checkbalance(e);
break;
case 2:
c[k].withdrawcash();
break;
case 3:
c[k].depositcash();
break;
case 4:
cout<<"\n\n\t\tThank You!!! for using our ATM\n\n";
goto Rakhav;
break;
case 5:
exit(0);
default:
cout<<"\nInvalid Entry!!";
goto loop;
break;
}
cout<<"\nDo you wish to have another transaction? (1/0)";
17
cin>>r;
}while(r);
}
5.OUTPUT:SCREENSHOT :
18
19
20
21
22
23
6.CONCLUSIONThus the project for ATM System in C++ using oops was implemented. It contains all the
basic transaction that occurred in atm day to day life. The program must contain ten user accounts.
The user can use our ATM to withdraw money, check balance enquiry and deposit cash to his
account. Implement this using various C++ concepts like inheritance, files, exception handling,
friend function.
24