Title: ATM Machine Simulation Using Java
Abstract
This project is a simple ATM Machine
simulation developed in Java. It includes
basic functionalities such as authentication,
balance inquiry, deposit, and withdrawal.
The system ensures user security through a
PIN-based login and maintains user account
details. The project is designed using
Object-Oriented Programming (OOP) and
Java principles.
---
Table of Contents
1. Introduction
2. Problem Statement
3. Objectives
4. System Requirements
5. Software and Tools Used
6. System Design
6.1 UML Diagrams
6.2 Class Diagram
7. Implementation
7.1 program of ATM machine
7.2 Code Explanation
8. Output of ATM machine code
9. Results and Observations
10. Future Enhancements
11. Conclusion
12. References
1. Introduction :
ATMs (Automated Teller Machines)
allow customers to perform basic
banking transactions without visiting a
bank branch. This project simulates an
ATM machine with limited
functionalities such as account
authentication, balance checking,
deposits, and withdrawals.
2. Problem Statement :
Traditional banking requires manual
intervention, which is time-consuming.
This project aims to create an ATM
simulation to help users manage their
bank accounts quickly and securely.
3. Objectives :
Simulate basic ATM functionalities
Implement user authentication through
PIN
Manage account transactions such as
deposits and withdrawals
Display account balance
Ensure security through PIN-based
access
4. System Requirements :
Hardware Requirements :-
I. Processor: Intel i3 or above
II. RAM: 4GB minimum
III. Storage: 500MB
IV. Software Requirements
V. Java Development Kit (JDK)
VI. Integrated Development
Environment (IDE) (Eclipse, IntelliJ, or
NetBeans)
---
5. Software and Tools Used :
I. Java: Core programming language
II. Eclipse/IntelliJ: IDE for development
III. UML Diagram Tools: Draw.io or
StarUML
6. System Design :
6.1 UML Diagrams:-
Use case diagram showing user interactions
Class diagram showing the relationship
between different classes
6.2 Class Diagram:-
Classes Used:
1. ATM - Main class to start the application
2. BankAccount - Manages account details
3. Transaction - Handles deposits and
withdrawals
4. UserAuthentication - Manages PIN-based
authentication
7.1 Program of ATM machine
ATM.java
import java.util.Scanner;
class Account {
private String accountNumber;
private String accountHolderName;
private double balance;
private String pin; // Added PIN for security
public Account(String accountNumber, String
accountHolderName, double balance, String pin) {
this.accountNumber = accountNumber;
this.accountHolderName =
accountHolderName;
this.balance = balance;
this.pin = pin;
}
// Get account number
public String getAccountNumber() {
return accountNumber;
}
// Get account holder name
public String getAccountHolderName() {
return accountHolderName;
}
// Get balance
public double getBalance() {
return balance;
}
// Verify PIN
public boolean verifyPin(String enteredPin) {
return this.pin.equals(enteredPin);
}
// Deposit method
public void deposit(double amount) {
if (amount > 0) {
balance += amount;
System.out.println("Successfully deposited $"
+ amount);
} else {
System.out.println("Invalid deposit
amount!");
}
}
// Withdrawal method
public void withdraw(double amount) {
if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("Successfully withdrawn
$" + amount);
} else {
System.out.println("Insufficient balance or
invalid amount!");
}
}
// Display balance
public void checkBalance() {
System.out.println("\n Account Details =====");
System.out.println("Account Holder: " +
accountHolderName);
System.out.println("Account Number: " +
accountNumber);
System.out.println("Account Balance: $" +
balance);
}
}
public class MiniATM {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
// Create an account with PIN
System.out.println("Create Your Account ");
System.out.print("Enter Account Number: ");
String accNumber = scanner.nextLine();
System.out.print("Enter Account Holder Name:
");
String accHolderName = scanner.nextLine();
System.out.print("Enter Initial Balance: ");
double initialBalance = scanner.nextDouble();
scanner.nextLine();
System.out.print("Set a 4-digit PIN: ");
String pin = scanner.nextLine();
// Validate PIN length
while (pin.length() != 4 || !pin.matches("\\
d{4}")) {
System.out.print("Invalid PIN! Enter a 4-digit
PIN: ");
pin = scanner.nextLine();
}
Account account = new Account(accNumber,
accHolderName, initialBalance, pin);
System.out.println("\nAccount Created
Successfully!\n");
while (true) {
System.out.println("\nMini ATM ");
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Check Balance");
System.out.println("4. Exit");
System.out.print("Choose an option: ");
int choice = scanner.nextInt();
scanner.nextLine();
if (choice == 4) {
System.out.println("Thank you for using
my ATM");
scanner.close();
return;
}
// PIN verification with 3 attempts
boolean authenticated = false;
for (int attempts = 1; attempts <= 3;
attempts++) {
System.out.print("Enter your 4-digit PIN:
");
String enteredPin = scanner.nextLine();
if (account.verifyPin(enteredPin)) {
authenticated = true;
break;
} else {
System.out.println("Incorrect PIN!
Attempts left: " + (3 - attempts));
}
}
if (!authenticated) {
System.out.println("Too many incorrect
pin! Exiting...");
break;
}
switch (choice) {
case 1:
System.out.print("Enter deposit amount:
");
double depositAmount =
scanner.nextDouble();
account.deposit(depositAmount);
break;
case 2:
System.out.print("Enter withdrawal
amount: ");
double withdrawAmount =
scanner.nextDouble();
account.withdraw(withdrawAmount);
break;
case 3:
account.checkBalance();
break;
default:
System.out.println("Invalid option!
Please try again.");
}
}
}
}
7.2 Code Explanation
This Java program simulates a Mini ATM
System that allows users to:
1. Create an Account (with an account
number, holder name, balance, and a 4-digit
PIN).
2. Perform Banking Operations such as
deposit, withdrawal, and balance check.
3. PIN Authentication with a maximum of 3
attempts for security.
4. Exit the system when finished.
Code Breakdown
1. Account Class (Encapsulation of Account
Details)
Private attributes: Stores account details
securely.
Constructor: Initializes account details.
Methods:
getAccountNumber(),
getAccountHolderName(), getBalance() →
Retrieve details.
verifyPin(String enteredPin) → Checks if the
entered PIN is correct.
deposit(double amount), withdraw(double
amount) → Perform transactions.
checkBalance() → Display account details.
2. MiniATM Class (Main Program)
Account Creation:
The user provides account details.
PIN validation ensures a 4-digit numeric PIN.
Menu Options (Infinite Loop Until Exit):
1. Deposit: Adds money to the account.
2. Withdraw: Checks balance and allows
withdrawal.
3. Check Balance: Displays account details.
4. Exit: Terminates the program.
PIN Authentication:
The system asks for the PIN before each
transaction.
Users have 3 attempts; if all fail, the session
exits.
Key Features
✅ Encapsulation: Data is secured inside the
Account class.
✅ Input Validation: Ensures a valid PIN and
transaction amounts.
✅ Security: Allows only 3 PIN attempts before
locking out.
✅ User-friendly Interface: Clear prompts and
messages for smooth interaction.
8.Output Of ATM Machine Code
Create Your Account
Enter Account Number: 9637010009715
Enter Account Holder Name: Sangram Shivaji
Patil
Enter Initial Balance: 989999
Set a 4-digit PIN: 9730
Account Created Successfully!
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 1
Enter your 4-digit PIN: 9730
Enter deposit amount: 20000
Successfully deposited $20000.0
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 3
Enter your 4-digit PIN: 9730
Account Details =====
Account Holder: Sangram Shivaji Patil
Account Number: 9637010009715
Account Balance: $1009999.0
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 2
Enter your 4-digit PIN: 9730
Enter withdrawal amount: 20000
Successfully withdrawn $20000
Mini ATM
1. Deposit
2. Withdraw
3. Check Balance
4. Exit
Choose an option: 3
Enter your 4-digit PIN: 2563
Incorrect PIN! Attempts left: 2
Enter your 4-digit PIN: 426
Incorrect PIN! Attempts left: 1
Enter your 4-digit PIN: 537
Incorrect PIN! Attempts left: 0
Too many incorrect pin! Exiting...
[Program finished]
9. Results and Observations :
Users can securely access their accounts with a
PIN.
Deposit and withdrawal transactions work
correctly.
Error handling for invalid amounts and
incorrect PIN is functional.
10. Future Enhancements :
Implement multiple user accounts
Add a graphical user interface (GUI)
Integrate database for real-time data
storage
Provide mini statement generation
11. Conclusion :
This project successfully simulates an ATM
machine with basic banking functionalities.
The use of OOP ,JAVA principles ensures
modular, scalable, and maintainable code.
12. References :
Java Documentation:
https://docs.oracle.com/javase/
Java Tutorials: https://www.jav
atpoint.com/java-tutorial