This ICSE Computer Applications project contains the implementation of Banking Management System in Java BlueJ environment. Students can use this as a reference for their own projects.
Complete code and BlueJ output is provided below:
Account.java
/**
* Account class of Banking Management Project.
*
* @author knowledgeboat.com
* @version 1.0
*/
public class Account
{
private long acNo;
private String acHolderName;
private char acType; //'S' for saving, 'C' for current
private double acBal;
public Account(long no, String name,
char type, double bal) {
acNo = no;
acHolderName = name;
acType = type;
acBal = bal;
}
public long getAcNo() {
return acNo;
}
public String getAcHolder() {
return acHolderName;
}
public char getAcType() {
return acType;
}
public double getAcBal() {
return acBal;
}
public void deposit(double amt) {
acBal += amt;
}
public boolean withdraw(double amt) {
if (acBal < amt)
return false;
acBal -= amt;
return true;
}
public void displayAcDetails() {
System.out.println("Account No. : " + acNo);
System.out.println("Account Holder Name : " + acHolderName);
System.out.println("Type of Account : " + acType);
System.out.println("Balance Amount : " + acBal);
}
}
Bank.java
/**
* Bank class of Banking Management Project.
*
* @author knowledgeboat.com
* @version 1.0
*/
import java.util.Scanner;
public class Bank
{
private final int TOTAL_ACCTS_LIMIT = 10;
private Account[] accts;
private int acCount;
public Bank() {
accts = new Account[TOTAL_ACCTS_LIMIT];
acCount = 0;
}
private Account getAccount(long accNo) {
Account acct = null;
for (int i = 0; i < acCount; i++) {
if (accts[i].getAcNo() == accNo) {
acct = accts[i];
break;
}
}
return acct;
}
public void openAccount() {
if (acCount == TOTAL_ACCTS_LIMIT) {
System.out.println("Limit reached, can't create more than " +
TOTAL_ACCTS_LIMIT + " accounts");
return;
}
Scanner in = new Scanner(System.in);
System.out.println("Enter Account Number: ");
long acNum = in.nextLong();
in.nextLine();
System.out.println("Enter Account Holder Name: ");
String name = in.nextLine();
System.out.println("Enter Account Type (Savings(S)/Current(C)): ");
char type = in.next().charAt(0);
System.out.println("Enter Account Balance: ");
double bal = in.nextDouble();
accts[acCount++] = new Account(acNum, name, type, bal);
System.out.println("Account Opened Successfully\n");
}
public void balanceEnquiry() {
Scanner in = new Scanner(System.in);
System.out.println("Enter Account Number: ");
long acNum = in.nextLong();
Account acct = getAccount(acNum);
if (acct == null) {
System.out.println("Sorry, Account not found\n");
}
else {
acct.displayAcDetails();
}
System.out.println();
}
public void makeDeposit() {
Scanner in = new Scanner(System.in);
System.out.println("Enter Account Number: ");
long acNum = in.nextLong();
System.out.println("Enter Amount: ");
double amt = in.nextDouble();
Account acct = getAccount(acNum);
if (acct == null) {
System.out.println("Sorry, Account not found");
}
else {
acct.deposit(amt);
System.out.println("Deposit Successful");
System.out.println("Updated Account Details");
acct.displayAcDetails();
}
System.out.println();
}
public void makeWithdrawal() {
Scanner in = new Scanner(System.in);
System.out.println("Enter Account Number: ");
long acNum = in.nextLong();
System.out.println("Enter Amount: ");
double amt = in.nextDouble();
Account acct = getAccount(acNum);
if (acct == null) {
System.out.println("Sorry, Account not found");
}
else {
if (acct.withdraw(amt)) {
System.out.println("Withdrawal Successful");
System.out.println("Updated Account Details");
}
else {
System.out.println("Insufficient Balance!!!");
System.out.println("Account Details");
}
acct.displayAcDetails();
}
System.out.println();
}
public void displayAllAccounts() {
System.out.println("A/C No.\tNAME\tTYPE\tBALANCE");
for (int i = 0; i < acCount; i++) {
System.out.println(accts[i].getAcNo() + "\t"
+ accts[i].getAcHolder() + "\t" + accts[i].getAcType() + "\t"
+ accts[i].getAcBal());
}
System.out.println();
}
public static void main(String args[]) {
int ch;
Bank bank = new Bank();
do {
System.out.println("Main Menu");
System.out.println("1. Open New Account");
System.out.println("2. Deposit Amount");
System.out.println("3. Withdraw Amount");
System.out.println("4. Check Balance");
System.out.println("5. List All Accounts");
System.out.println("6. Exit");
System.out.println("Make Your Choice (1-6): ");
Scanner in = new Scanner(System.in);
ch = in.nextInt();
System.out.println();
switch(ch) {
case 1:
bank.openAccount();
break;
case 2:
bank.makeDeposit();
break;
case 3:
bank.makeWithdrawal();
break;
case 4:
bank.balanceEnquiry();
break;
case 5:
bank.displayAllAccounts();
break;
case 6:
System.out.println("Bye...");
break;
default:
System.out.println("Incorrect choice!!!");
}
} while (ch != 6);
}
}