0% found this document useful (0 votes)
18 views4 pages

Banking System Simulator Java

This document outlines a beginner-level Java project that simulates a basic banking system using Object-Oriented Programming. It includes a `BankAccount` class with attributes and methods for account management, along with a user interaction loop for creating accounts, depositing, withdrawing, and checking balances. The project emphasizes concepts such as encapsulation, constructors, method overloading, and data validation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views4 pages

Banking System Simulator Java

This document outlines a beginner-level Java project that simulates a basic banking system using Object-Oriented Programming. It includes a `BankAccount` class with attributes and methods for account management, along with a user interaction loop for creating accounts, depositing, withdrawing, and checking balances. The project emphasizes concepts such as encapsulation, constructors, method overloading, and data validation.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Banking System Simulator (OOP Project

in Java)
This beginner-level project will allow students to simulate a basic bank account system
using Object-Oriented Programming in Java.

🔧 Features:
- Create a class `BankAccount`

- Attributes: `accountHolder`, `balance`, `accountNumber`

- Methods: `deposit()`, `withdraw()`, `checkBalance()`

🔁 Sample Interaction:

1. Create account
2. Deposit money
3. Withdraw money
4. Check balance
5. Exit

🎯 Concepts Practiced:
- Encapsulation

- Constructors

- Method overloading

- Data validation

Starter Code (BankAccount.java & BankApp.java)


File: BankAccount.java

public class BankAccount {


private String accountHolder;
private double balance;
private String accountNumber;
public BankAccount(String accountHolder, String accountNumber) {
this.accountHolder = accountHolder;
this.accountNumber = accountNumber;
this.balance = 0.0;
}

public void deposit(double amount) {


if (amount > 0) {
balance += amount;
System.out.println("Deposited: ₱" + amount);
} else {
System.out.println("Invalid deposit amount.");
}
}

public void withdraw(double amount) {


if (amount > 0 && amount <= balance) {
balance -= amount;
System.out.println("Withdrawn: ₱" + amount);
} else {
System.out.println("Insufficient balance or invalid amount.");
}
}

public void checkBalance() {


System.out.println("Account Holder: " + accountHolder);
System.out.println("Account Number: " + accountNumber);
System.out.println("Current Balance: ₱" + balance);
}
}

File: BankApp.java

import java.util.Scanner;

public class BankApp {


public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
BankAccount account = null;

while (true) {
System.out.println("\n1. Create account");
System.out.println("2. Deposit money");
System.out.println("3. Withdraw money");
System.out.println("4. Check balance");
System.out.println("5. Exit");
System.out.print("Choose an option: ");
int choice = scanner.nextInt();

switch (choice) {
case 1:
scanner.nextLine(); // consume leftover newline
System.out.print("Enter account holder name: ");
String name = scanner.nextLine();
System.out.print("Enter account number: ");
String accNum = scanner.nextLine();
account = new BankAccount(name, accNum);
System.out.println("Account created successfully!");
break;
case 2:
if (account != null) {
System.out.print("Enter amount to deposit: ");
double deposit = scanner.nextDouble();
account.deposit(deposit);
} else {
System.out.println("Please create an account first.");
}
break;
case 3:
if (account != null) {
System.out.print("Enter amount to withdraw: ");
double withdraw = scanner.nextDouble();
account.withdraw(withdraw);
} else {
System.out.println("Please create an account first.");
}
break;
case 4:
if (account != null) {
account.checkBalance();
} else {
System.out.println("Please create an account first.");
}
break;
case 5:
System.out.println("Thank you for using the banking system. Goodbye!");
return;
default:
System.out.println("Invalid option. Try again.");
}
}
}
}

Sample Student Answer (Write-up)

In this project, I created a class `BankAccount` that models a simple bank account. I added
fields for the account holder's name, balance, and account number. I implemented deposit
and withdraw methods with checks for invalid input and insufficient balance. The project
helped me understand how to encapsulate data and how objects interact with user input in
the main class. I also added simple validation logic to make the simulation more realistic.

You might also like