Case study like: ATM

Comprehensive study notes, diagrams, and exam preparation for Case study like: ATM.

Case Study Like: ATM

Definition

An ATM is an electronic banking machine that enables customers to perform financial transactions automatically using a card, PIN, and menu-based interface, while the software behind it manages authentication, account access, transaction processing, error handling, and data storage.

In programming terms, an ATM system is a transaction-driven application that:

  • accepts user input,
  • processes banking logic,
  • maintains account data,
  • handles invalid conditions safely,
  • and supports efficient access to multiple records and operations.

It is a classic example of an integrated software system because it requires:

Strings

  • for text-based inputs such as card numbers, PINs, and operation commands,

Exception handling

  • for runtime errors and invalid actions,

Multi-threading

  • for concurrent transaction support,

Data collections

  • for storing and managing structured data like accounts and receipts.

Main Content

1. User Authentication and String Handling

  • The ATM first identifies the customer through inputs such as card number, PIN, and sometimes OTP or biometric details. These values are often handled as strings because they are textual and may contain leading zeros, special formatting, or fixed lengths.
  • String operations are essential for validation and security. For example, the system may check whether the PIN length is exactly 4 digits, whether the card number contains only numeric characters, or whether the entered transaction command matches a valid menu option like "withdraw" or "balance".

String handling in an ATM is not limited to simple input reading. It also includes:

  • trimming extra spaces,
  • comparing user-entered values with stored values,
  • masking sensitive information,
  • and formatting messages for display.

Example:

  • Card number: "1234 5678 9012 3456"
  • PIN: "0456"
    Here, PIN should be treated as a string so that the leading zero is not lost. If treated as a number, "0456" becomes 456, which is incorrect in many banking contexts.

Common string-related checks in ATM software:

  • Is the input empty?
  • Does the PIN contain exactly 4 digits?
  • Does the account number match the stored record?
  • Is the selected menu option valid?

These checks make the ATM reliable, user-friendly, and safe from invalid input.

2. Transaction Processing and Exception Handling

  • An ATM must handle many possible errors during execution. This is where exception handling becomes very important. The system should not crash if a user enters wrong data or if a banking rule is violated. Instead, it should catch the problem and show a meaningful message.
  • Exceptions are especially useful in situations like insufficient balance, invalid PIN attempts, exceeded withdrawal limit, network failure, card expiration, or account locking after multiple failed logins.

An ATM transaction may fail for several reasons:

  • The amount requested is more than the available balance.
  • The user enters a negative withdrawal amount.
  • The bank server is not reachable.
  • The cash dispenser has insufficient notes.
  • The user tries too many incorrect PIN attempts.

A well-designed ATM uses exception handling to:

  • detect the error,
  • stop unsafe operations,
  • notify the user clearly,
  • and allow the system to continue safely.

Example scenarios:

  • If a user tries to withdraw ₹10,000 while the balance is only ₹4,500, the program can throw an InsufficientBalanceException.
  • If the network connection to the bank server is lost, a NetworkFailureException may be generated.
  • If the user enters "abc" instead of a numeric withdrawal amount, the program may throw an input format exception.

This concept is critical because financial systems must be secure and dependable. A small unhandled error in banking software can cause data corruption or wrong transactions. Thus, exception handling ensures robustness and trustworthiness.

3. Multi-threading and Data Collections

  • A modern ATM system may serve many users at the same time across different terminals. To support this, software can use multi-threading, where each transaction or user session runs as a separate thread. This allows the system to handle multiple operations concurrently without waiting for one task to finish completely before another begins.

Data collections

  • are used to store and manage account-related information efficiently. These may include lists of accounts, maps of card numbers to customer profiles, queues of transaction requests, and sets of blocked cards. Collections help the program organize large amounts of banking data in a structured and accessible way.

Multi-threading in ATM systems:

  • One thread can handle card verification.
  • Another can process cash withdrawal.
  • Another can update transaction logs.
  • Another can print receipts.

This improves performance and makes the system scalable.

Data collections in ATM systems:

  • List for transaction history
  • Map for account lookup by account number or card number
  • Set for blacklisted cards
  • Queue for pending requests

Example of data structure usage:

  • A Map<String, Account> can store account numbers as keys and account objects as values.
  • A List<Transaction> can store every transaction made by a customer.
  • A Set<String> can store blocked ATM cards so the system can quickly check whether access should be denied.

The combination of multi-threading and collections is important because ATMs must be fast, organized, and capable of handling concurrent access without errors such as data inconsistency or lost updates.


Working / Process

1. Card insertion and user verification

The user inserts a card or enters account details. The ATM reads the card number and asks for the PIN. The system validates the input using string checks and compares it with stored account data. If the PIN is wrong, the system may allow limited retries and then block the session if the limit is exceeded.

2. Menu selection and transaction execution

After successful authentication, the ATM displays options such as balance inquiry, cash withdrawal, deposit, or transfer. The user chooses an option, and the system performs the required action. During this stage, exception handling is used to manage invalid amounts, unavailable funds, server issues, or unsupported operations.

3. Update records and complete the session

Once the transaction is successful, the ATM updates the account information, stores the transaction in a collection such as a list or database table, and may print a receipt. If multiple users are being processed, different threads manage different sessions independently, ensuring smooth and efficient operation.

For better understanding, the flow can be visualized like this:

Card Inserted
     |
     v
Enter PIN ---> Validate PIN ---> Correct?
     |                         /       \
     |                        No        Yes
     |                        |          |
     v                        v          v
Retry / Block            Error Message  Show Menu
                                             |
                                             v
                                  Select Operation
                                             |
                                             v
                                 Process Transaction
                                             |
                                             v
                                   Update Data / Log
                                             |
                                             v
                                      Session Ends

Advantages / Applications

  • ATMs provide 24-hour access to banking services, allowing users to withdraw cash, check balances, and transfer money at any time without visiting a branch.
  • They reduce human workload and improve speed by automating common banking operations, making them highly efficient for both customers and financial institutions.
  • They serve as a practical model for learning software concepts such as string processing, exception management, concurrency, and collections because they combine all these features in a single system.

Other important applications of ATM-like systems include:

  • self-service kiosks in airports and hospitals,
  • ticket vending machines,
  • online banking portals,
  • payment terminals,
  • and automated customer service systems.

ATMs are also useful in software education because they show:

  • how secure input validation works,
  • how to handle runtime errors gracefully,
  • how concurrent users can be supported,
  • and how structured data can be stored and retrieved efficiently.

Summary

  • An ATM is a practical banking system that performs automatic financial transactions using secure user authentication and structured processing.
  • It is a strong case study because it connects strings, exception handling, multi-threading, and data collections in one real-life application.
  • The core idea is to accept user input, validate it, process the transaction safely, and update records accurately.
  • Important terms to remember: ATM, PIN, authentication, transaction, exception handling, multi-threading, data collections, account, balance, withdrawal.