Open links in new tab
    • Work Report
    • Email
    • Rewrite
    • Speech
    • Title Generator
    • Smart Reply
    • Poem
    • Essay
    • Joke
    • Instagram Post
    • X Post
    • Facebook Post
    • Story
    • Cover Letter
    • Resume
    • Job Description
    • Recommendation Letter
    • Resignation Letter
    • Invitation Letter
    • Greeting Message
    • Try more templates
  1. An ATM program in Java simulates basic banking operations such as withdrawing cash, depositing money, checking balance, and viewing the last transaction. Below is an example implementation using a switch-case structure for simplicity.

    import java.util.Scanner;

    public class ATM {
    public static void main(String[] args) {
    int balance = 50000;
    String lastTransaction = "No transactions made";
    int pin = 1234;

    Scanner sc = new Scanner(System.in);
    System.out.print("Enter your PIN: ");
    int enteredPin = sc.nextInt();

    if (enteredPin != pin) {
    System.out.println("Access denied. Incorrect PIN.");
    return;
    }

    System.out.println("Welcome to the ATM!");
    while (true) {
    System.out.println("\n1. Withdraw Cash");
    System.out.println("2. Deposit Cash");
    System.out.println("3. Check Balance");
    System.out.println("4. View Last Transaction");
    System.out.println("5. Exit");
    System.out.print("Enter your choice: ");
    int choice = sc.nextInt();

    switch (choice) {
    case 1: // Withdraw Cash
    System.out.print("Enter the amount to withdraw: ");
    int withdraw = sc.nextInt();
    if (withdraw > 0 && withdraw <= balance) {
    balance -= withdraw;
    lastTransaction = "You withdrew: Rs." + withdraw;
    System.out.println("Withdrawal successful! Please take your cash.");
    } else if (withdraw > balance) {
    System.out.println("Insufficient funds! Please try a smaller amount.");
    } else {
    System.out.println("Invalid amount. Please try again.");
    }
    break;

    case 2: // Deposit Cash
    System.out.print("Enter the amount to deposit: ");
    int deposit = sc.nextInt();
    if (deposit > 0) {
    balance += deposit;
    lastTransaction = "You deposited: Rs." + deposit;
    System.out.println("Deposit successful! Thank you.");
    } else {
    System.out.println("Invalid amount. Please try again.");
    }
    break;

    case 3: // Check Balance
    System.out.println("Your current balance is: Rs." + balance);
    break;

    case 4: // View Last Transaction
    System.out.println("Last transaction: " + lastTransaction);
    break;

    case 5: // Exit
    System.out.println("Thank you for using the ATM. Have a great day!");
    sc.close();
    return;

    default:
    System.out.println("Invalid choice. Please select a valid option.");
    }
    }
    }
    }
    Copied!
    Feedback
  2. ATM Program JAVA - Online Tutorials Library

    In this article, we will learn how to build a simple ATM machine program in Java. This program lets users choose from the options displayed on the screen. Before choosing the options, the user has to enter …

  3. GitHub - TAIMOURMUSHTAQ/ATM-Simulator-Java: A simple Java ATM …

    A simple console-based ATM (Automated Teller Machine) system implemented in Java. This project is designed for beginners to understand core Java OOP concepts while simulating basic ATM operations.

  4. simple ATM Project in Java-covering full CRUD (without DB, using ...

    Jul 26, 2025 · Here's a simple ATM Project in Java that includes Account Creation, View, Deposit, Withdraw, and Deletion – covering full CRUD (without DB, using console + Java basics).

  5. Creating a Banking ATM Simulator in Java: An Object-Oriented ...

    Learn how to build a banking ATM simulator in Java using object-oriented programming concepts. Perfect for beginners and advanced learners!

  6. ATM Simulation System Using Java With Source Code

    This Command-Line User Interface (CLI)-based ATM Stimulation System offers a clear and easy way to execute withdrawals, deposits, and check balances. Java is …