ATM Transaction Program in Java

Baruni Priya T S
2 min readJun 8, 2021

Overview

In this blog, we will learn to build a Java program that will carry out a simple ATM transaction where the user can perform operations like withdraw, deposit and balance check.

Operations That Can Be Performed

  1. Withdraw
  2. Deposit
  3. Checking Balance
  4. Exit

Algorithm for Each Operation

A. Withdraw:

  1. Input the amount from the user that he/she wishes to withdraw.
  2. If the withdrawal amount is less than or equal to balance amount (i.e. withdrawalAmount ≤ balanceAmount), then perform the transaction (i.e. balanceAmount = balanceAmount — withdrawalAmount) and give the user’s desired amount.
  3. Else, print a message on the screen stating that the balance is insufficient.

B. Deposit:

  1. Input the amount from the user that he/she wishes to deposit.
  2. Add the deposit amount to the balance amount in the bank and update its value (i.e. balanceAmount = balanceAmount + depositAmount).
  3. Print a message on the screen stating that the transaction is successful.

C. Checking Balance:

When the user desires to check the balance amount in the bank, display the value of the balance amount on the screen.

D. Exit:

When the user chooses the exit option, exit the current transaction mode and end the program.

Source Code

Here is the complete source code of a Java program that carries out the operations of a simple ATM transaction:

Source Code

Are you looking to master coding and crack top company interviews? Go ahead and try GUVI’s Pro Subscription to help you with everything needed to build a strong Technical Career.

Know more about GUVI:

Also, download GUVI’s app to learn the latest IT skills in vernacular languages.

--

--