ATM 542 Merged
ATM 542 Merged
Project Report on
ATM MACHINE
Submitted for partial fulfilment of the requirements for the award of the degree
of
JANUARY - 2024
St. MARTIN'S ENGINEERING COLLEGE
UGC Autonomous
Accredited by NBA & NAAC A+
Dhulapally, Secunderabad-500 100
www.smec.ac.in
CERTIFICATE
This is to certify that the project entitled “VENDING MACHINE” is being
submitted by N. Dhanush Reddy (22K81A0542) in fulfilment of the requirement
for the award of degree of BACHELOR OF TECHNOLOGY IN COMPUTER
SCIENCE AND ENGINEERING is recorded of bonafide work carried out by
them. The result embodied in this report have been verified and found satisfactory.
DECLARATION
The satisfaction and euphoria that accompanies the successful completion of any
task would be incomplete without the mention of the people who made it possible
and whose encouragement and guidance have crowded our efforts with success.
First and foremost, we would like to express our deep sense of gratitude and
indebtedness to our College Management for their kind support and permission to
use the facilities available in the Institute.
We especially would like to express our deep sense of gratitude and indebtedness
to Dr. P. SANTOSH KUMAR PATRA, Group Director, St. Martin’s
Engineering College Dhulapally, for permitting us to undertake this project.
We wish to record our profound gratitude to Dr. M. SREENIVAS RAO,
Principal, St. Martin’s Engineering College, for his motivation and
encouragement.
We are also thankful to Dr. R. SANTHOSH KUMAR, Head of the Department,
Computer Science And Engineering, St. Martin’s Engineering College,
Dhulapally, Secunderabad, for his support and guidance throughout our project.
We would like to express our sincere gratitude and indebtedness to our project
supervisor Mr. Y. Peer Mohideen Assistant Professor, Department of Computer
Science and Engineering, St. Martins Engineering College, Dhulapally, for his/her
support and guidance throughout our project. Finally, we express thanks to all
those who have helped us successfully completing this project. Furthermore, we
would like to thank our family and friends for their moral support and
encouragement. We express thanks to all those who have helped us in successfully
completing the project.
CHAPTER 1- ABSTRACT 1
CHAPTER 2- INTRODUCTION 2
CHAPTER 5- ALGORITHM 5
CHAPTER 9- CONCLUSION 19
The Program titled ‘ATM MACHINE’ is implemented in JAVA, The Java code represents a rudimentary
yet functional ATM system with an intuitive graphical user interface developed using the Swing library. It
comprises two main classes: `Login` and `ATM`. The `Login` class orchestrates the initial interaction,
prompting users to input a personal identification number (PIN) with a limited number of attempts. Upon
successful authentication, users are seamlessly redirected to the `ATM` class, where the primary
transactional functionalities unfold. Within the `ATM` interface, users are empowered to engage in a variety
of financial operations, including withdrawals of specific denominations (₹500, ₹1000, and ₹2000), fund
deposits, balance inquiries, and the seamless termination of the session through the log-out option. Each of
these functionalities is intricately implemented through event listeners, ensuring responsive user interactions.
The GUI employs Swing components for an interactive and visually appealing layout.The code incorporates
fundamental input validation, guaranteeing that withdrawal operations are contingent upon adequate account
balances. The system maintains an organized transaction history, offering users a comprehensive receipt
upon concluding their ATM session. Despite the program's operational efficiency, opportunities for
enhancement abound. Modularizing the code, adopting constants to replace magic numbers, refining error
handling mechanisms, and implementing robust security practices, especially concerning sensitive data like
PINs, are areas for improvement. Furthermore, the user interface could benefit from design refinements to
enhance usability and provide a more polished and user-friendly experience.
1
2. INTRODUCTION
2
3. SYSTEM ANALYSIS
The current code represents a basic ATM system with a Swing-based GUI. It includes a PIN-based
login system, allowing users to perform transactions such as withdrawals, deposits, and balance
inquiries. The user interface provides a straightforward yet functional experience.
The proposed system aims to elevate the existing ATM simulation by introducing modular design
for improved organization, advanced security measures including secure credential storage, enhanced
user feedback and validation, enum-based representation of transaction types for readability, and a
polished user interface with improved aesthetics and user-friendly features. These enhancements
collectively aim to provide a more secure, maintainable, and engaging ATM experience.
3
4 . SYSTEM REQUIREMENTS
1. Operating System: The code is written in Java, so it is platform independent. It can run on
variousoperating systems such as Windows, Linux, and macOS.
2. Processor (CPU): A basic processor with moderate speed is sufficient. The code does not have
intensive processing requirements.
3. Memory (RAM): A small amount of RAM is needed to run desktop applications. Typically, 2GB
or more of RAM should be more than enough.
4. Storage: The storage requirements are minimal. The code itself is small, and the game data is
managed within the application. A few megabytes of free storage space would be more than adequate.
5. Graphics: The code uses Java's Swing library for GUI, which is not graphics-intensive. Most
standard integrated graphics solutions on modern computers should handle it without any issues.
6. Input Devices: The game is designed to be played with a mouse or touchpad for clicking on the
graphical buttons.
4
5. ALGORITHM
STEP 1: START
STEP 2: Initialize crucial variables for managing the ATM system, including `balance`,
`inputSequence`, `transactionHist`, `inputSequenceIndex`, `transactionIndex`, and `readyToEnter`.
STEP 3: Implement the Login Screen, verifying the PIN, and allowing limited login attempts before
transitioning to the ATM screen.
STEP 4: Initialize the ATM screen, configure UI components, display the current balance, and
provide transaction instructions.
STEP 5: Define button actions:
- Withdraw Buttons: Check and deduct funds, provide feedback on success or insufficient funds.
- Quit Button: Display a receipt, bid farewell, and return to the login screen.
- Clear Button: Reset input, update display, and deactivate `readyToEnter`.
- Number Buttons (0-9): Capture input if `readyToEnter` is true.
- Enter Button: Process input, update balance, transaction history, and display transaction outcome.
STEP 6: Manage a dynamic `transactionList` ArrayList to record each transaction for user reference.
STEP 7: Implement a method to generate a comprehensive receipt containing the transaction history.
STEP 8: Maintain a continuous loop for user-friendly interactions; exit the loop upon user request.
STEP 9: Allow users to return to the login screen for subsequent sessions, ensuring a secure process.
STEP 10: STOP
5
6. SYSTEM IMPLEMENTATION
SOURCE CODE
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.ArrayList;
public Login() {
super("Login Screen");
setLayout(new BorderLayout());
setResizable(false);
setLocationRelativeTo(null);
buildApp();
pack();
setSize(250, 110);
setVisible(true);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
void buildApp() {
quit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
System.exit(0);
}
});
pinText.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event)
6
char[] pinGuess = pinText.getPassword(); String pinString =
new String(pinGuess); if (pinString.equals(pin)) {
JOptionPane.showMessageDialog(null, "That pin is correct! Opening Account...");
dispose();
new ATM();
} else {
if (attempts != 1) {
attempts--;
JOptionPane.showMessageDialog(null,
"That pin is incorrect! \n" + attempts + " attempts remaining!");
} else {
JOptionPane.showMessageDialog(null, "No Attempts remaining! \n Closing Program");
System.exit(0);
}
}
}
});
entPin.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
char[] pinGuess = pinText.getPassword();
String pinString = new String(pinGuess);
if (pinString.equals(pin)) {
JOptionPane.showMessageDialog(null, "That pin is correct! Opening Account...");
dispose();
new ATM();
} else {
if (attempts != 1) {
attempts--;
JOptionPane.showMessageDialog(null,
"That pin is incorrect! \n" + attempts + " attempts remaining!");
} else {
JOptionPane.showMessageDialog(null, "No Attempts remaining! \n Closing Program");
System.exit(0);
}
}
}
});
}
}
public ATM() {
super("ATM");
for (int i = 0; i <= 3; i++) {
7
inputSequence[i] = "";
}
setResizable(false);
setLocationRelativeTo(null);
buildApp();
pack();
setSize(600, 350);
setVisible(true);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
JLabel displayArea = new JLabel("<html>Instruction Area: <br> Please select a function from the buttons
below <br> Current Balance: ₹"
+ balance + "</html>");
displayArea.setOpaque(true);
displayArea.setBackground(Color.white);
displayArea.setPreferredSize(new Dimension(100, 100));
JPanel bottomArea = new JPanel();
bottomArea.setLayout(new BorderLayout(0, 0));
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new BorderLayout(0, 0));
JLabel inputDisplay = new JLabel("Input Area:");
inputDisplay.setBorder(BorderFactory.createLineBorder(Color.black));
bottomArea.add(inputDisplay, BorderLayout.NORTH);
bPConst.weightx = 0.1;
bPConst.weighty = 0.1;
JButton withDraw1 = new JButton("Withdraw ₹500");
bPConst.gridx = 0;
bPConst.gridy = 0;
bPConst.insets = new Insets(0, 0, 5, 5);
withDraw1.setSize(new Dimension(200, 30));
buttonPanel.add(withDraw1, bPConst);
JButton withDraw2 = new JButton("Withdraw ₹1000");
bPConst.gridx = 0;
bPConst.gridy = 1;
withDraw2.setSize(new Dimension(200, 30));
buttonPanel.add(withDraw2, bPConst);
JButton withDraw3 = new JButton("Withdraw ₹2000");
bPConst.gridx = 0;
bPConst.gridy = 2;
withDraw3.setSize(new Dimension(200, 30));
buttonPanel.add(withDraw3, bPConst);
JButton deposit = new JButton("Deposit");
bPConst.gridx = 0;
bPConst.gridy = 3;
deposit.setSize(new Dimension(200, 30));
8
buttonPanel.add(deposit, bPConst);
JButton quit = new JButton("Quit");
bPConst.gridx = 0;
bPConst.gridy = 4;
bPConst.anchor = GridBagConstraints.PAGE_END;
quit.setSize(new Dimension(200, 30));
buttonPanel.add(quit, bPConst);
JButton number1 = new JButton("1");
bPConst.gridx = 1;
bPConst.gridy = 0;
number1.setSize(new Dimension(200, 30));
buttonPanel.add(number1, bPConst);
JButton number2 = new JButton("2");
bPConst.gridx = 2;
bPConst.gridy = 0;
number2.setSize(new Dimension(200, 30));
buttonPanel.add(number2, bPConst);
JButton number3 = new JButton("3");
bPConst.gridx = 3;
bPConst.gridy = 0;
number3.setSize(new Dimension(200, 30));
buttonPanel.add(number3, bPConst);
JButton number4 = new JButton("4");
bPConst.gridx = 1;
bPConst.gridy = 1;
number4.setSize(new Dimension(200, 30));
buttonPanel.add(number4, bPConst);
JButton number5 = new JButton("5");
bPConst.gridx = 2;
bPConst.gridy = 1;
number5.setSize(new Dimension(200, 30));
buttonPanel.add(number5, bPConst);
JButton number6 = new JButton("6");
bPConst.gridx = 3;
bPConst.gridy = 1;
number6.setSize(new Dimension(200, 30));
buttonPanel.add(number6, bPConst);
JButton number7 = new JButton("7");
bPConst.gridx = 1;
bPConst.gridy = 2;
number7.setSize(new Dimension(200, 30));
buttonPanel.add(number7, bPConst);
JButton number8 = new JButton("8");
bPConst.gridx = 2;
bPConst.gridy = 2;
number8.setSize(new Dimension(200, 30));
buttonPanel.add(number8, bPConst);
JButton number9 = new JButton("9");
bPConst.gridx = 3;
bPConst.gridy = 2;
number9.setSize(new Dimension(200, 30));
buttonPanel.add(number9, bPConst);
JButton number0 = new JButton("0");
9
bPConst.gridx = 1;
bPConst.gridy = 3;
number0.setSize(new Dimension(200, 30));
buttonPanel.add(number0, bPConst);
JButton clear = new JButton("Clear");
bPConst.gridx = 2;
bPConst.gridy = 3;
clear.setSize(new Dimension(200, 30));
buttonPanel.add(clear, bPConst);
JButton enter = new JButton("Enter");
bPConst.gridx = 3;
bPConst.gridy = 3;
enter.setSize(new Dimension(200, 30));
buttonPanel.add(enter, bPConst);
bottomArea.add(buttonPanel, BorderLayout.CENTER);
add(displayArea, BorderLayout.NORTH);
add(bottomArea, BorderLayout.CENTER);
withDraw1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (balance >= 500) {
balance = balance - 500;
displayArea.setText("<html>₹500 Withdrawn! <br><br>" + finishedTransaction() + "</html>");
readyToEnter = false;
System.out.println("User Has Withdrawn ₹500");
updateTransactionHist("User Has Withdrawn ₹500");
} else {
displayArea.setText("<html> Your Balance is below ₹500. Unable to Withdraw!! <br><br>"
+ finishedTransaction() + "</html>");
}
}
});
withDraw2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (balance >= 1000) {
balance = balance - 1000;
displayArea.setText("<html>₹1000 Withdrawn! <br><br>" + finishedTransaction() + "</html>");
readyToEnter = false;
System.out.println("User Has Withdrawn ₹1000");
updateTransactionHist("User Has Withdrawn ₹1000");
} else {
displayArea.setText("<html> Your Balance is below ₹1000. Unable to Withdraw!! <br><br>"
+ finishedTransaction() + "</html>");
}
}
});
withDraw3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (balance >= 2000) {
balance = balance - 2000;
displayArea.setText("<html>₹2000 Withdrawn! <br><br>" + finishedTransaction() + "</html>");
10
readyToEnter = false;
System.out.println("User Has Withdrawn ₹2000");
updateTransactionHist("User Has Withdrawn ₹2000");
} else {
displayArea.setText("<html> Your Balance is below ₹2000. Unable to Withdraw!! <br><br>"
+ finishedTransaction() + "</html>");
quit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
JOptionPane.showMessageDialog(null, "Your Receipt: \n" + printReceipt());
JOptionPane.showMessageDialog(null, "Logging Out! Returning to Login Screen!");
dispose();
new Login();
}
});
clear.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: ");
displayArea.setText("<html>Input Area Cleared! <br><br>" + finishedTransaction() + "</html>");
clearInput();
readyToEnter = false;
}
});
number1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("1"));
}
});
number2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("2"));
}
});
number3.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("3"));
}
});
number4.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("4"));
}
});
number5.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("5"));
}
});
number6.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("6"));
}
});
number7.addActionListener(new ActionListener() {
11
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("7"));
}
});
number8.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
});
inputDisplay.setText("Input Display: " + updateInput("8"));
}
});
number9.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("9"));
}
});
number0.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
inputDisplay.setText("Input Display: " + updateInput("0"));
}
});
deposit.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
displayArea.setText("<html> Deposit Selected! <br> Please input an amount below or equal to
₹10000 and click enter! <br><br>"
+ finishedTransaction() + "</html>");
readyToEnter = true;
}
});
enter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
if (readyToEnter == true) {
if (Integer.parseInt(getInputSequence()) > 10000) {
displayArea.setText("That input is greater than ₹10000!");
clearInput();
inputDisplay.setText("Input Display: ");
readyToEnter = false;
} else if (Integer.parseInt(getInputSequence()) == 0 || getInputSequence().equals("0000")) {
displayArea.setText("You have not entered a value!");
clearInput();
inputDisplay.setText("Input Display: ");
readyToEnter = false;
} else {
updateBalance(Integer.parseInt(getInputSequence()));
displayArea.setText("<html>You have deposited ₹" + getInputSequence()
+ "! <br><br>" + finishedTransaction() + "</html>");
System.out.println("User Has Deposited ₹" + getInputSequence());
updateTransactionHist("User Has Deposited ₹" + getInputSequence());
}
clearInput();
inputDisplay.setText("Input Display: ");
readyToEnter = false;
12
} else {
displayArea.setText("<html>You have not yet chosen an action! <br><br>" +
finishedTransaction() + "</html>");
clearInput();
inputDisplay.setText("Input Display: ");
}
}
});
}
void clearInput() {
}
inputSequenceIndex = 0;
}
String updateInput(String n) {
if (inputSequenceIndex <= 3) {
inputSequence[inputSequenceIndex] = n;
inputSequenceIndex++;
String getInputSequence() {
StringBuilder strBuilder = new StringBuilder();
if (inputSequence[0].equals("")) {
return "0000";
} else {
for (int i = 0; i < inputSequence.length; i++) {
strBuilder.append(inputSequence[i]);
}
String newString = strBuilder.toString();
return newString;
}
}
String finishedTransaction() {
return "Instruction Area: <br> Please select a function from the buttons below <br> Current Balance: ₹" +
13
balance;
}
void updateBalance(int l) {
balance += l;
}
void updateTransactionHist(String t) {
transactionHist.add(t);
}
String printReceipt() {
14
7. SYSTEM TESTING
Input:
Please Enter the pin - 1234
** pin – 1234 **
Expected Output :
Input:
Instruction Area:
Please select a function from the buttons below
Current Balance: ₹10
*Pressed withdraw 500 button*
` Expected Output:
Instruction Area:
Please select a function from the buttons below
Current Balance: ₹10
Input:
Instruction Area:
Please select a function from the buttons below
Current Balance: ₹10
*Pressed Deposit button*
Expected Output:
Deposit Selected!!.
Please enter an amount of upto 10000₹ and click enter.
Input Display: 5000
** Click Enter **
15
You have Deposied
₹5000!!
Instruction Area:
Please select a function from the buttons below
Current Balance: ₹5010
` Expected Output:
Instruction Area:
Please select a function from the buttons below
Current Balance: ₹3010
16
8. OUTPUT SCREENS
8.1 – Screen
8.2 – Screen
17
8.3 – Screen
8.4 - Screen
18
9. CONCLUSION
In conclusion, the provided JAVA code The provided Java code presents a simple yet effective simulation
of an Automated Teller Machine (ATM) system through two main classes: `Login` and `ATM`. The
`Login` class governs the secure login process, where users are required to enter a Personal Identification
Number (PIN). A limited number of attempts are allowed, and successful authentication leads to the opening
of the ATM screen, managed by the `ATM` class. The `ATM` class encapsulates various ATM
functionalities within a graphical user interface (GUI). Users can perform actions such as balance inquiry,
cash withdrawal with varying amounts, and fund deposits. The interface is designed with intuitive buttons,
contributing to a user-friendly experience. Input validation mechanisms are in place to handle scenarios like
insufficient funds or incorrect PIN entries. The system keeps track of user activities by maintaining a
transaction history. Users have the option to generate a receipt, providing a comprehensive overview of their
recent transactions upon choosing to quit the session. The code's structure reflects a modular approach with
two distinct classes, promoting readability and ease of maintenance
19
10. FUTURE ENHANCEMENTS
1. Multi-User Support:
- Implement a user account system, allowing multiple users to have personalized accounts with
unique PINs and balances.
2. Transaction Categorization:
-Classify transactions into categories (e.g., withdrawals, deposits) for a more organized transaction
history.
-Enable users to view transaction history based on categories.
3. Overdraft Protection:
- Introduce an overdraft protection feature to prevent users from overdrawing their account balances.
- Notify users of low balances and provide options to transfer funds or take necessary actions.
4. Transaction Limits:
- Set transaction limits for withdrawals and deposits to enhance security and prevent fraudulent
activities.
- Allow users to customize their transaction limits within permissible bounds.
5. Currency Handling:
- Extend the system to handle multiple currencies, providing international users with a more
versatile experience.
- Implement currency conversion functionalities for cross-currency transactions.
20
11. REFERENCES
1. https://docs.oracle.com/en/java/
2. https://www.javatpoint.com/java-swing
3. https://www.geeksforgeeks.org/java/
4. https://www.tutorialspoint.com/swing/swing_quick_guide.htm
5. https://www.geeksforgeeks.org/java/
6. https://www.java.com/en/
7. https://github.com/topics/java-project
8. https://github.com/topics/java-project
9. https://www.tutorialspoint.com/java/index.htm
10. https://www.codechef.com/roadmap/java-dsa
21