EXCEPTION HANDLING-
ATM TRANSACTIONS
OOPThroughjavaLabProject BachelorofTechnology lll
semester In Computer Science and Engineering By
S ABHILASH (24261A0550)
Under the guidance of
[Link] ALPHY
DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING
MAHATMA GANDHI INSTITUTE OF TECHNOLOGY GANDIPET,
HYDERABAD-500075, TELANGANA 2024-2025
CERTIFICATION
This is to certify that the OOP Through java Lab project entitled “EXCEPTION
HANDLING-ATM TRANSACTION ” is being submitted by S ABHILASH bearing Roll No:
24261A0550 in the partial fulfilment for the award of Bachelor of
Technology III semester in Computer Science and Engineering to Mahatma Gandhi
Institute of Technology is a record of bona- fide work carried out under the
guidance and supervision. The report is based on the work done entirely by us and-
not copied from any other source.
Project guide Head of the Department
[Link] ALPHY Dr. C. R. K. Reddy
[Link],[Link] CSE Professor,[Link] CSE
DECLARATION
This is to certify that the work reported in this Student grade points Project titled
“EXCEPTION HANDLING-ATM TRANSACTIONS ” is a record of work done by me in the
Department of Computer Science and Engineering, Mahatma Gandhi Institute and
Technology, Hyderabad. No part of the work is copied from books/journals/internet and
wherever the portion is taken, the same has been duly
referred to in the text. The report is based on the work done entirely by us and not
copied from any other source.
S ABHILASH (24261A0550)
ACKNOWLEDGEMENT
The satisfaction that accompanies the successful completion of any task would be
incomplete without the mention of people who made it possible because success is
the abstract of hard work and perseverance, but steadfast of all is encouraging
guidance. So, We acknowledge all those whose guidance and encouragement
served as a beacon light and crowned my efforts with success.
We would like to express my sincere thanks to Prof. G. Chandra Mohan Reddy,
Principal, MGIT, for providing the working facilities in the college.
We wish to express my sincere thanks and gratitude to Dr. C. R. K. Reddy,
Professor and HOD, Department of CSE, MGIT for all the timely support and
valuable suggestions during the period of project.
We are extremely thankful to Dr. MEERA ALPHY , Department of CSE, MGIT for their
encouragement and support throughout the project.
Finally, we would also like to thank all the faculty and staff of the CSE
Department who helped us directly or indirectly for completing this project.
S ABHILASH (24261A0550)
TABLE OFCONTENTS
CERTIFICATE …………………………………………………………………… 2
DECLARATION...................................................................................................................................
ACKNOWLEDGEMENT..........................................................................................................................
ABSTRACT................................................................................................................................................
1. INTRODUCTION.........................................................................................................................................
1.1 Methodology…………………………………………………………………………….
2. RESULT………………………………………………………………………………… 10
3. CONCLUSION AND FUTURE SCOPE……………………………………………… 19
3.1 Conclusion…………………………………………………………….
3.2 Future scope……………………………………………………………
4. REFERENCES………………………………………………………………………….21
ABSTRACT
This The ATM Transaction GUI Program is a Java-based desktop application designed to simulate a simplified ATM
withdrawal process through an intuitive graphical user interface. Developed using Java Swing, the project demonstrates
fundamental concepts of object-oriented programming, event-driven programming, and GUI development. The primary
objective of the system is to provide users with an interactive platform to perform withdrawal transactions while receiving
real-time feedback on their current account balance.
The application initializes with a predefined balance and presents users with a clear interface containing four
key components: a balance display label, an input field for entering withdrawal amounts, a withdrawal button,
and a message label for displaying status updates. The layout is constructed using a 4×1 GridLayout to
maintain simplicity and ease of navigation. Users can input their desired withdrawal amount, and upon clicking
the “Withdraw” button, the system processes the request through a series of validation checks.
The program employs exception handling mechanisms to ensure transaction reliability and prevent incorrect
operations. It verifies whether the entered amount is a valid numerical value, checks for non-positive values,
and ensures that the requested amount does not exceed the current balance. Depending on the outcome, the
system updates the balance dynamically and provides appropriate feedback messages regarding successful
transactions or encountered errors such as invalid input or insufficient funds.
By leveraging Swing's event-handling features, the application ensures smooth user interaction and real-time
updates without interrupting the program flow. The use of the Event Dispatch Thread (EDT) further enhances
the program’s efficiency and stability, ensuring thread-safe GUI execution. Overall, the ATM Transaction GUI
Program offers a practical demonstration of integrating GUI components, validation logic, and exception
handling to create a functional and user-friendly application. It serves as an excellent learning project for
beginners exploring Java GUI development and basic financial transaction simulations.
1. INTRODUCTION
The ATM Transaction GUI Program is a basic Java application designed to demonstrate how graphical user interfaces can
be used to simulate real-world banking operations. Developed using the Java Swing framework, the program focuses on
one of the most common ATM functions—withdrawing money—while providing users with a simple, interactive
experience. The project serves as an excellent introduction to GUI development, event handling, layout management, and
exception handling in Java.
The program begins with a predefined account balance and presents the user with a clean, four-component interface.
This includes a label showing the current balance, a text field for entering the withdrawal amount, a button to perform
the withdrawal, and a message label for displaying feedback. When the user enters an amount and clicks the “Withdraw”
button, the application processes the input through a series of validations. These checks ensure that the input is a valid
number, that it is positive, and that the user has enough balance to complete the withdrawal.
By updating the balance in real-time and providing immediate feedback, the program mimics the essential behavior of a
real ATM. Additionally, the use of exception handling enhances program stability by preventing invalid operations.
Through its simplicity and practical approach, the ATM Transaction GUI Program helps beginners understand key Java
concepts while demonstrating how GUI applications can be used to build interactive financial tools.
--
Code:
import [Link].*;
import [Link].*;
import [Link].*;
// ATM Transaction GUI Program
public class ATMTransactionGUI extends JFrame {
// GUI component declarations
private JTextField amountField;
private JButton withdrawButton;
private JLabel balanceLabel;
// Initial balance stored as a variable
private double balance = 1000.00;
// Constructor to set up the GUI
public ATMTransactionGUI() {
// Set window title
setTitle("ATM Transaction");
// Set window size
setSize(400, 200);
// Close program when window is closed
setDefaultCloseOperation(EXIT_ON_CLOSE);
// 4 rows, 1 column layout
setLayout(new GridLayout(4, 1));
// Label to display current balance
balanceLabel = new JLabel("Current Balance: ₹" + balance);
add(balanceLabel);
// Text field to enter withdrawal amount
amountField = new JTextField();
[Link]("Enter amount to withdraw");
add(amountField);
// Withdraw button
withdrawButton = new JButton("Withdraw");
add(withdrawButton);
// Label to display success/error messages
JLabel messageLabel = new JLabel("");
add(messageLabel);
// Action listener for the withdraw button
[Link](new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
// Convert input text into a number
double amount = [Link]([Link]());
// Check if amount is positive
if (amount <= 0) {
throw new IllegalArgumentException("Amount must be positive.");
}
// Check if balance is sufficient
if (amount > balance) {
throw new Exception("Insufficient balance.");
}
// Deduct amount from balance
balance -= amount;
// Update balance label
[Link]("Current Balance: ₹" + balance);
// Show success message
[Link]("Withdrawal successful: ₹" + amount);
} catch (NumberFormatException ex) {
// Handles invalid number format
[Link]("Invalid input. Please enter a number.");
} catch (IllegalArgumentException ex) {
// Handles negative or zero input
[Link]([Link]());
} catch (Exception ex) {
// Handles insufficient balance
[Link]("Transaction failed: " + [Link]());
}
}
});
}
// Main method to launch the GUI
public static void main(String[] args) {
// Ensure GUI runs safely on Event Dispatch Thread
[Link](() -> {
new ATMTransactionGUI().setVisible(true);
});
}
2. RESULT
The output represents the graphical user interface (GUI) of the ATM Transaction Program
created using Java Swing. The window displays the current account balance, an input field
to enter the withdrawal amount, a button to perform the withdrawal, and a message area
to show the result of the transaction.
In the example shown in the image:
The current balance is displayed as ₹1000.00.
The user enters the withdrawal amount in the text field.
After clicking the Withdraw button, the system processes the transaction.
.