VOOZH about

URL: https://www.geeksforgeeks.org/java/java-program-to-display-the-atm-transaction/

⇱ Java Program to Display the ATM Transaction - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java Program to Display the ATM Transaction

Last Updated : 19 Dec, 2025

ATM (Automated Teller Machine) transaction system allows users to perform basic banking operations such as withdrawing money, depositing funds, and checking account balance. This Java program simulates core ATM functionality using simple methods and conditional logic.

Supported ATM Operations

The program supports the following operations:

  • Withdraw: Deducts a specified amount from the account if sufficient balance is available
  • Deposit: Adds a specified amount to the account balance
  • Check Balance: Displays the current account balance
  • Exit: Terminates the transaction flow

Approach

A. Withdraw:

  • Accepts the withdrawal amount as input
  • Checks whether the available balance is sufficient
  • Deducts the amount if possible, otherwise prints an insufficient funds message

B. Deposit:

  • Accepts the deposit amount as input
  • Adds the amount to the existing balance
  • Displays a success message along with the updated balance

C. Check Balance: Prints the current balance available in the account

D. Exit: Ends the transaction process


Output
Current Balance : 10000

Withdrawing Amount : 5000
Please collect your money and card.
Current Balance : 5000

Depositing Amount : 2000
Deposit successful.
Current Balance : 7000

Explanation:

  • main() initializes balance, withdrawAmount, and depositAmount, then displays the initial balance using displayBalance(balance).
  • amountWithdrawing() checks sufficient balance and deducts the withdrawal amount using balance = balance - withdrawAmount.
  • amountDepositing() adds the deposit amount using balance = balance + depositAmount and prints the updated balance.
Comment