-
Notifications
You must be signed in to change notification settings - Fork 0
Home
Welcome to the ATM System Wiki.
This project is a Java-based ATM application with a Swing GUI that simulates banking operations such as balance inquiry, withdrawal, deposit, and loan calculation.
- Overview
- System Structure
- User Interface
- PIN Authentication
- ATM Functions
- Loan Calculator
- Input Validation
- Receipt Generation
- Key Concepts
- Execution Flow
- Advantages
- Language: Java
- Framework: Swing (GUI)
- Type: Desktop Application
This system demonstrates essential banking features in a secure and modular manner.
public class ATMS extends javax.swing.JFrame
-
Extends JFrame to create the main application window.
-
Handles GUI initialization and event-driven logic.
private double currentBalance = 1000.0;
private int pinAttempts = 0;
private static final int MAX_PIN_ATTEMPTS = 3;
-
currentBalance → tracks account balance.
-
pinAttempts → tracks failed PIN entries.
-
MAX_PIN_ATTEMPTS → maximum retry attempts allowed.
The GUI layout is divided into panels:
-
Panel 1: Balance & Withdraw controls.
-
Panel 2: Central display (PIN entry, status).
-
Panel 4: Numeric keypad.
-
Panel 5: Loan calculator.
-
Panel 6: Loan & Deposit controls.
Example button creation:
jbtnBalance = new javax.swing.JButton();
jbtn1 = new javax.swing.JButton();
Each button is mapped to an event handler.
private void jbtnEnterActionPerformed(java.awt.event.ActionEvent evt) {
int pin = Integer.parseInt(jlblDisplay.getText());
if (pin == 1234) {
jbtnBalance.setEnabled(true);
jlblPinStatus.setText("Access Granted");
} else {
pinAttempts++;
if (pinAttempts >= MAX_PIN_ATTEMPTS) {
disableAllButtons();
}
}
}
-
Compares input against stored PIN.
-
Locks application after 3 failed attempts.
private void jbtnBalanceActionPerformed(java.awt.event.ActionEvent evt) {
jlblDisplay.setText("£" + String.format("%.2f", currentBalance));
}
Displays account balance formatted with 2 decimal places.
Withdrawal
java
Copy
Edit
private void jbtnWithdrawActionPerformed(java.awt.event.ActionEvent evt) {
String input = JOptionPane.showInputDialog(this, "Enter amount to withdraw:");
double amount = Double.parseDouble(input);
if (amount <= currentBalance) {
currentBalance -= amount;
} else {
JOptionPane.showMessageDialog(this, "Insufficient funds");
}
}
Checks available funds before allowing withdrawal.
(Similar implementation, adds value to balance instead of subtracting.)
private void updateInterestRate() {
double loanAmount = Double.parseDouble(jtxtEnteloanamount.getText());
double interestRate;
if (loanAmount >= 100000) {
interestRate = 6.0;
} else if (loanAmount >= 20000) {
interestRate = 5.5;
} else {
interestRate = 5.0;
}
jtxtInterestRate.setText(String.format("%.1f%%", interestRate));
}
Applies rate based on loan amount:
-
≥ £100,000 → 6%
-
£20,000–£99,999 → 5.5%
-
< £20,000 → 5%
double monthlyPayment = loanAmount * monthlyInterestRate /
(1 - Math.pow(1 + monthlyInterestRate, -totalMonths));
Standard amortization formula to compute monthly payments.
private void jtxtEnteloanamountKeyTyped(java.awt.event.KeyEvent evt) {
char character = evt.getKeyChar();
if (!(Character.isDigit(character) || character == '.' || character == KeyEvent.VK_BACK_SPACE)) {
evt.consume();
}
}
Ensures only numeric input (0–9), decimal points, and backspace are allowed.
jtxtReceipt.append("\t\tLoan Management System\n");
jtxtReceipt.append("Reference:\t\t\t" + refs + "\n");
jtxtReceipt.append("Amount of Loan:\t\t\t£" + loanAmount + "\n");
Generates a structured receipt containing:
-
System header
-
Reference number
-
Loan amount
-
Date and time
-
Event-Driven Programming → Each button triggers a specific action.
-
Object-Oriented Design → Components encapsulated as objects.
-
Exception Handling → Prevents runtime crashes due to invalid inputs.
-
Data Validation → Ensures input consistency.
-
Application initializes GUI.
-
User enters PIN → authentication occurs.
-
ATM operations enabled (Balance, Withdraw, Deposit, Loan).
-
Loan calculator evaluates interest and repayment.
-
System generates receipts.
Modular: Each feature encapsulated in separate methods.
Secure: PIN authentication with retry limits.
Professional Output: Financial formatting and receipts.
Extendable: Future enhancements (e.g., database connectivity).