Sei sulla pagina 1di 23

PREFACE

Language is a medium of communication. People can interact


with each other if they know a common language. Similarly a
user can interact with the computer only if he/she knows a
computer language.
Computer languages are broadly classified into two types low-
level languages and high-level languages. The high level
language is further classified into two types. They are:
1. Procedure Oriented
2. Object Oriented
Java is one of this powerful object oriented programming
language that is used to build secure and powerful
applications that run across multiple OS. It was developed by
James gosling and Patrick Naughton for Sun Microsystems Inc.
in 1991, and it was later acquired by Oracle Corporation.
This whole project for ATM was developed using Java in BlueJ.

PAGE 1
Acknowledgement

PAGE 2
Contents
Page
Preface 1
Acknowledgement 2
Introduction 4
Objective 5
Function Implemented 6
Coding 7-17
Output Screenshots 18-20
Variable description 21
Use of different Methods
Conclusion
Bibliography

PAGE 3
Introduction

PAGE 4
Objective
The real objective behind this project is to give us an practical
experience on programming and developing with JAVA.
Our project was very simple and it was based on ATM and
here we were directed to code and develop a very simple user
interface of ATM using JAVA which is seen , experienced and
used by most of us in the bank ATMs. The main objective
behind this project was not only to gain marks in this subject
but also to enhance our knowledge of programing with JAVA.
While doing this project we learnt the use of various new
methods, escape sequences, new techniques and many thing.
It gave me a real-life experience on how to deal with various
kind of errors and how to make a system user-friendly. I think
in future it’d be really this experience would be really helpful
to me.

PAGE 5
Function Implemented
This program for ATM developed using JAVA can perfom all
task which a real Bank ATM can. Using this program the user
can:--
1. Create a new account
2. Withdraw Money
3. Deposit Money
4. Send Money To Any Other User
5. Change his/her Pin
6. Check his/her Balance
The aim of the code is to create a very simple interface for the
user which everyone could use even without the much
knowledge of technology. Here the Math.random() function
was also used to generate a random unique pin(4-digit) and a
unique account no.(10-digit) for the user every he/she creates
a account. Various kind of error handlings for various kind of
wrong inputs were added here so that the user can
understand his mistake(say a wrong pin input) and use this
system without any problem and at the same time the
complete security of this system maintained. So that no 2nd
person can any how get the details of the account of a user
and use his/her account. If the users enters a wrong pin to
maintain security on thing is added here which’d allow the
user to try again with the correct pin only for three times.

PAGE 6
Coding
import java.util.Scanner;

class atm_project

{ String user_name=" ",user_add=" ";

int pin,re_pin,balance,d_ac_check,temp,trial,temp_2;

double ac_no=0.0,range_2=(9999999999.0-1000000000.0+1.0); //range for user ac_no

int range=(9999-1000+1); //range for user pin code generation

atm_project() //constructor

{ pin=0; re_pin=0;balance=0;ac_check=0;temp=0;trial=3;temp_2=0; //default value intialized

Scanner sc=new Scanner(System.in);

void ac_create() //method for creating account

{ if(ac_check==1) //checking whether a account is created or not

System.out.println("Already you have created one account");

return;

else

System.out.println("-----------------------------------------Create Account---------------------------- --------------------


----");

System.out.println("Enter your name :");

user_name=sc.nextLine();

System.out.println("Enter your full address : ");

user_add=sc.nextLine();

System.out.println("Enter the first amount you want to deposit (min Rs 1000) :");

balance=sc.nextInt();

PAGE 7
for(int i=0; i<=300;)

{ if(balance >=1000) // in case the deposit amount is less than Rs. 1000(error handling)

break;

else

System.out.println("You need to deposit a minimum amount of Rs 1000");

System.out.println("Again enter the first amount you want to deposit (min Rs 1000) :");

balance=sc.nextInt();

pin=(int)(Math.random()*range+1000); // generating random pin for the user

ac_no=(Math.random()*range_2+1000000000.0); // generating account no. for the user

System.out.println("Your account is created successfully !");

System.out.println();

System.out.println("-----------------------------------------Account details------------------------------------------------
----");

System.out.println("User name : "+user_name);

System.out.println("Address : "+user_add);

System.out.println("PIN No : "+pin);

System.out.println("Account No : "+(long)ac_no); //converting ac_no to long as account no. cannot be in


decimals

System.out.println("Balance : "+balance);

ac_check=1; //changing ac_check to 1 as one account is created (this variable is later used to check
whether a account is created or not)

void withdraw() //method to withdraw money

{ trial=3;

if(ac_check ==1) //checking whether a account is created or not

{ System.out.println("-----------------------------------------Withdraw Money-------------------------------------------
---------");

PAGE 8
System.out.println("Welcome "+user_name);

for(int i=1;i<=300;)

System.out.println();

System.out.println("Enter your pin :");

temp=sc.nextInt();

if(temp==pin)

System.out.println("Enter the amt. you want to withdraw :");

temp=sc.nextInt();

if(temp < balance)

{ System.out.println("Rs. "+temp+" is withdrawn successfully !");

balance=balance-temp;

System.out.println("Current Balance : Rs. "+balance);

return;

else

{ System.out.println("Insufficient Balance");

System.out.println("Current Balance : Rs. "+balance);

return ;

else

if(trial == 0) //only 3 chances to re_enter the pin in case wrong pin is entered

{System.out.println("You have entered the pin wrong four times no trials left");

return;

PAGE 9
System.out.println("Wrong pin entered");

System.out.println("Try again");

System.out.println("You have "+trial+" trials left");

System.out.println("Re-enter your pin correctly :");

trial--;

else

{ System.out.println("No account created");

return;

void user_deposit() //method to deposit money

{ if(ac_check==1) //checking whether a account is created or not

{ System.out.println("-----------------------------------------Deposit Money----------------------------------------------
------");

System.out.println("Enter the amount of money you want to deposit(in Rs.) :");

temp=sc.nextInt();

balance=balance+temp;

System.out.println("Rs. "+temp+" is successfully deposited");

System.out.println("Current Balance : "+balance);

else

System.out.println("No account created");

void send_money() //method to send money

PAGE 10
{ trial=3; //it is the no. of times the user can try to enter the pin in case he enters a wrong pin

if(ac_check==1)

{ System.out.println("-----------------------------------------Money Transfer-----------------------------------------
-----------");

for(int i=1;i<=300;)

{ System.out.println("Welcome "+user_name);

System.out.println("Enter your pin :");

temp=sc.nextInt();

if(temp==pin)

{ System.out.println("Enter the account details of the person you are sending money------");

System.out.println("Enter the account no. of the person(10-digit) :");

temp_2=sc.nextInt();

int num=temp_2,count=0;

for(int j=0;j<=300;)

while(num>0) //for checking the given account no. is of 10 digit or not

num=num/10;

count++;

if(count==10)

{ System.out.println("Enter the amount of money you want to send :");

temp=sc.nextInt();

if(balance>=temp) //to check the balance is sufficient or not

{ System.out.println("Money sent successfully to----- ");

System.out.println("Account No: "+temp_2);

balance=balance-temp;

System.out.println("Current Balance : "+balance);

return;

PAGE 11
}

else

{ System.out.println("Insufficient Balance");

else

{ System.out.println("Wrong Input");

System.out.println("Enter a 10 digit account no.");

System.out.println("Choose the option again from menu to continue");

System.out.println("wait.... ");

return;

else

{ if(trial == 0)

{ System.out.println("You have entered the pin wrong four times no trials left");

return;

System.out.println("Wrong pin entered");

System.out.println("Try again");

System.out.println("You have "+trial+" trials left");

System.out.println("Re-enter your pin correctly :");

trial--;

else

PAGE 12
{ System.out.println("No Account created !"); }

void pin_change() //method to change pin

{ if(ac_check==1)

{ System.out.println("-----------------------------------------User PIN Change--------------------------------------------


--------");

for(int i=1;i<=300;)

{ System.out.println();

System.out.println("Enter your pin :"); //checking with the old pin

temp=sc.nextInt();

if(temp == pin)

System.out.println("Enter your desired pin(4-digit) :");

pin=sc.nextInt();

for(int j=0;j<=300;)

{int num=pin,digit_c=0;

while(num>0) //for checking whether the given pin is of four digit or not

{ num=num/10;

digit_c++;

if(digit_c==4)

{ break;

else

{ System.out.println("Enter only a four digit pin e.g 1234 :"); //in case it is more or less than 4-digit

pin=sc.nextInt(); //again input is taken

} System.out.println("Re-enter it:");

re_pin=sc.nextInt();

PAGE 13
trial=3;

for(int k=0; k<=300;)

{ if(pin == re_pin)

break;

else

System.out.println("Wrongly Entered");

System.out.println("Enter it correctly:");

re_pin=sc.nextInt();

System.out.println("Pin Changed Successfully !");

return;

else

if(trial == 0)

{ System.out.println("You have entered the wrong pin four times no trials left");

System.out.println("\u000C"); //clearing the terminal window

return;

System.out.println("Wrong pin entered");

System.out.println("Try again");

System.out.println("You have "+trial+" trials left");

System.out.println("Re-enter your pin correctly :");

trial--;

else

PAGE 14
{ System.out.println("At first create a account");

void bal_check() //method to check the user’s balance

{trial = 3;

if(ac_check==1)

{ for(int i=1;i<=300;)

{ System.out.println();

System.out.println("Enter your pin :"); //checking with the pin

temp=sc.nextInt();

if(temp == pin)

{System.out.println("User name \t: \t"+user_name);

System.out.println("Address \t: \t"+user_add);

System.out.println("Account No \t: \t"+(long)ac_no);//converting ac_no to long as account no. cannot be


in decimals

System.out.println("Balance \t: \t"+balance);

return;

else

{ if(trial == 0)

{ System.out.println("You have entered the wrong pin four times no trials left");

System.out.println("\u000C");//clearing the terminal window

return;

System.out.println("Wrong pin entered");

System.out.println("Try again");

System.out.println("You have "+trial+" trials left");

PAGE 15
System.out.println("Re-enter your pin correctly :");

trial --;

}}}

else

{System.out.println("No account created");

public static void main()

{Scanner kb=new Scanner(System.in);

atm_project ob=new atm_project();

for(int i=1;i<=300;)

{ System.out.println("-----------------------------------------ATM Menu---------------------------------------------------
-");

System.out.println();

System.out.println("Choose one option from below (enter the number)");

System.out.println("1.Create Account ");

System.out.println("2.Withdraw Money ");

System.out.println("3.Deposit Money ");

System.out.println("4. Send Money ");

System.out.println("5. Change PIN ");

System.out.println("6. Balance Check ");

System.out.println("7.Exit ");

int choice=kb.nextInt();

switch(choice)

{case 1:

{ System.out.println("\u000C");//clearing the terminal window

ob.ac_create();

} break;

case 2:

PAGE 16
{ System.out.println("\u000C");//clearing the terminal window

ob.withdraw();

}break;

case 3:

{ System.out.println("\u000C");//clearing the terminal window

ob.user_deposit();

} break;

case 4:

{ System.out.println("\u000C");//clearing the terminal window

ob.send_money();

} break;

case 5:

{ System.out.println("\u000C");//clearing the terminal window

ob.pin_change();

} break;

case 6:

{ System.out.println("\u000C");//clearing the terminal window

ob.bal_check();

}break;

case 7:

{ System.out.println("\u000C");//clearing the terminal window

System.out.println("Exiting....");

System.exit(0); //to exit

}break;

default:

{System.out.println("Wrong choice enter between 1-7");

}}}}}

PAGE 17
Output Screenshots

PAGE 18
PAGE 19
PAGE 20
Variable Description
Variable Name Data Type Use
user_name String For storing user name

user_add String For storing user address

pin int For storing user pin

re_pin int To re-take the pin input from


user in certain cases
ac_check int Used to check whether a
account is created or not
temp int Used for holding certain
values temporarily
trial int It stores the value which
states the no. of times the
user can enter a pin in case
he enters the wrong pin
temp_2 int A 2nd variable used for
temporarily holding values.
ac_no double To store the account no. of
user
range_2 double To calculate the range for
user account no. generation
range int To calculate the range for
user pin code generation
i&j int Used as a loop variable

PAGE 21
PAGE 22

Potrebbero piacerti anche