Banking System Simulator Java
Banking System Simulator Java
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`
🔁 Sample Interaction:
1. Create account
2. Deposit money
3. Withdraw money
4. Check balance
5. Exit
🎯 Concepts Practiced:
- Encapsulation
- Constructors
- Method overloading
- Data validation
File: BankApp.java
import java.util.Scanner;
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.");
}
}
}
}
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.