DEV Community

Cover image for Simple Java Project: Simple Banking System Simulation (with Detailed Explanation)
Sharique Siddiqui
Sharique Siddiqui

Posted on • Edited on

Simple Java Project: Simple Banking System Simulation (with Detailed Explanation)

A Simple Banking System Simulation is an excellent Java project for beginners eager to practice classes, objects, user input, variables, methods, menu-driven programs, and state management. This project simulates banking basics like balance checks, deposits, and withdrawals—all through the console.

What Will This Banking System Do?

  • Allow users to check their account balance.
  • Make deposits and withdrawals.
  • Display account information.
  • Exit via a menu.
  • All data is stored in-memory—no external files or databases.

Concepts Practiced in This Project

  • Classes & Objects: Representing a bank account with fields and methods.
  • User Input: Using Scanner for seamless interaction.
  • Conditional Logic: Ensuring valid transactions (can’t withdraw more than the balance).
  • Menu-Driven Programs: Using loops and switch-case to navigate options.
  • Encapsulation: Using getters/setters for data protection.

Step 1: The BankAccount Class

First, define a class to represent accounts:

java
public class BankAccount {
    private String ownerName;
    private String accountNumber;
    private double balance;

    // Constructor
    public BankAccount(String ownerName, String accountNumber, double initialBalance) {
        this.ownerName = ownerName;
        this.accountNumber = accountNumber;
        this.balance = initialBalance;
    }

    // Deposit money
    public void deposit(double amount) {
        if (amount > 0) {
            balance += amount;
            System.out.println("Deposit successful!");
        } else {
            System.out.println("Amount must be positive.");
        }
    }

    // Withdraw money
    public void withdraw(double amount) {
        if (amount > 0 && amount <= balance) {
            balance -= amount;
            System.out.println("Withdrawal successful!");
        } else if (amount > balance) {
            System.out.println("Insufficient funds.");
        } else {
            System.out.println("Amount must be positive.");
        }
    }

    // Check balance
    public double getBalance() {
        return balance;
    }

    // Show account info
    public void displayInfo() {
        System.out.println("Account Holder: " + ownerName);
        System.out.println("Account Number: " + accountNumber);
        System.out.printf("Balance: %.2f\n", balance);
    }
}

Enter fullscreen mode Exit fullscreen mode

Explanation:

  • Fields hold the owner's name, account number, and balance.
  • Methods handle deposits, withdrawals (with validation), balance checks, and displaying info.
  • Encapsulation keeps sensitive data (private fields).
  • Feedback messages tell users if actions succeed or fail.

Step 2: The Main Program with Menu

Now, create the interface for users to interact with their account:

java
import java.util.Scanner;

public class BankingSystem {
    public static void main(String[] args) {
        // Set up account for demonstration
        BankAccount account = new BankAccount("John Doe", "123456789", 1000.0);

        Scanner scanner = new Scanner(System.in);
        int choice;

        do {
            System.out.println("\n--- Simple Banking System Menu ---");
            System.out.println("1. Check Balance");
            System.out.println("2. Deposit Money");
            System.out.println("3. Withdraw Money");
            System.out.println("4. Display Account Information");
            System.out.println("5. Exit");
            System.out.print("Enter your choice: ");
            choice = scanner.nextInt();

            switch (choice) {
                case 1:
                    System.out.printf("Current Balance: %.2f\n", account.getBalance());
                    break;
                case 2:
                    System.out.print("Enter deposit amount: ");
                    double depositAmount = scanner.nextDouble();
                    account.deposit(depositAmount);
                    break;
                case 3:
                    System.out.print("Enter withdrawal amount: ");
                    double withdrawAmount = scanner.nextDouble();
                    account.withdraw(withdrawAmount);
                    break;
                case 4:
                    account.displayInfo();
                    break;
                case 5:
                    System.out.println("Thank you for using our banking system. Goodbye!");
                    break;
                default:
                    System.out.println("Invalid choice! Please select 1-5.");
            }
        } while (choice != 5);

        scanner.close();
    }
}

Enter fullscreen mode Exit fullscreen mode

How it Works: Key Parts Explained

  • The main menu offers five options—each triggering the appropriate BankAccount method.
  • Deposit and withdraw amounts must be positive; withdrawals also check for sufficient balance.
  • All feedback is immediate, ensuring the user knows the result of each action.
  • Information is displayed in a clean, readable format.

How to Run This Project

1.Create two files in the same folder:

BankAccount.java

BankingSystem.java

2.Compile both:

text
javac BankAccount.java BankingSystem.java
Enter fullscreen mode Exit fullscreen mode

3.Run the program:

text
java BankingSystem
Enter fullscreen mode Exit fullscreen mode

Follow menu prompts to interact with your simulated bank account.

Possible Expansions

  • Allow multiple accounts (store a list of BankAccount objects).
  • Implement user authentication (username/password).
  • Add money transfers between accounts.
  • Persist data to a file (basic I/O).
  • Add an overdraft limit or account types (savings/current, etc.).

Why This Project is Perfect for Beginners

  • Teaches OOP design: Use of classes, objects, constructors, and encapsulation.
  • Real-world logic: Mimics familiar banking operations—deposits, withdrawals, info display. -** Menu navigation:** Menu-driven approach is the backbone of many CLI applications.
  • Input validation: Controls how and what users can do, building robust logic.

By building this Simple Banking System Simulation, you’ll combine multiple foundational Java skills into a usable, extendable mini-app—perfect for portfolios, practice, and jumping to even bigger projects!

Check out the YouTube Playlist for great java developer content for basic to advanced topics.

Please Do Subscribe Our YouTube Channel for clearing programming concept and much more ... : CodenCloud

Top comments (1)

Collapse
 
platineer profile image
Platineer • Edited

This is actually a really clean beginner project, especially the way you handled validation in the withdraw method. One small suggestion though, if you want to make it feel a bit more real-world, you could separate transaction types instead of just updating one balance. For example, you could simulate different sources like credit card and debit card activity, or even track a mini transaction history so users can see what happened instead of just the final balance.

Another upgrade could be adding multiple accounts using something like an ArrayList, then letting the user pick which account to interact with. That would make the menu flow feel closer to an actual banking system instead of a single hardcoded account.

What I like here is how it mirrors real banking logic in a simple way. Even basic apps today don’t just show one number, they separate things clearly depending on the source of funds. You’ll notice the same pattern if you’ve ever used apps from banks like First Abu Dhabi Bank. Their system splits balances across different accounts and cards, so users can easily distinguish between their credit card and debit card usage without confusion.

I remember helping someone understand that exact difference using their mobile app, and it was surprisingly similar to what you’re doing here in code. We ended up checking a guide on because it explained how the FAB app organizes balances and card details in a really simple way. It kind of clicked instantly once we compared it to how a basic banking system like this should structure data.

So yeah, you’re already on the right track. If you extend this with multiple account types or card-based logic, it’ll start looking less like a demo and more like something you’d actually see in production.