By Ayush Gupta
It allows users to create customer accounts, display account details, make deposits, and perform withdrawals.
The SecureCash Flow project is an efficient and user-friendly application. The project is a simple banking application that allows users to perform various banking operations like searching account numbers, displaying all the accounts, depositing money and withdrawing money, etc.
With this project, there is a secure cash flow in the banking system. It allows to create and manage bank accounts with basic operations.
Creating Accounts:
• Users specify how many bank accounts they want to create.
• For each account, users provide the account number, account holder's name, and initial balance.
Main Menu:
• Users are presented with a menu where they can choose from five options (1 to 5).
Display All Accounts (Option 1):
• It displays the account number, the account holder's name, and the account balance for each account.
Searching By the Account Number (Option 2):
•Users can enter an account number to search for a specific account. If the account is found, it displays the details of that account, including the account number, account holder's name, and balance. If the account is not found, it shows a message saying "Search Failed Account Not Found."
Deposit Money (Option 3):
•Users can enter an account number to specify where they want to deposit money. If the account is found, users can input the amount to be deposited.
The balance of the account is updated by adding the deposited amount.
Withdraw Money (Option 4):
•Users can enter an account number to specify where they want to withdraw money. The balance of the account is updated by subtracting the withdrawn amount.
Exit the Application (Option 5):
• Users can choose this option to exit the banking application.
Output: The program displays all the accounts and related information of accounts.
import java.util.Scanner; class Bank { private String accountNumber; private String accountHolderName; private long accountBalance; Scanner scanner = new Scanner(System.in); // Method to open an account void openAccount() { System.out.print("Enter Account Number: "); accountNumber = scanner.next(); System.out.print("Enter Account Holder's Name: "); accountHolderName = scanner.next(); System.out.print("Enter Account Balance: "); accountBalance = scanner.nextLong(); } // Method to display account details void showAccount() { System.out.println("Account Number: " + accountNumber + ", Account Holder: " + accountHolderName + ", Balance: " + accountBalance); } // Method to deposit money void deposit() { long amount; System.out.print("Enter Amount You Want to Deposit: "); amount = scanner.nextLong(); accountBalance += amount; } // Method to withdraw money void withdrawal() { long amount; System.out.print("Enter Amount You Want to Withdraw: "); amount = scanner.nextLong(); if (accountBalance >= amount) { accountBalance -= amount; } else { System.out.println("Insufficient Balance..Transaction Failed.."); } } // Method to search an account by account number boolean search(String accountNumberToFind) { if (accountNumber.equals(accountNumberToFind)) { showAccount(); return true; } return false; } } public class ExBank { public static void main(String args[]) { Scanner scanner = new Scanner(System.in); // Create initial accounts System.out.print("How Many Customers You Want to Input: "); int numberOfCustomers = scanner.nextInt(); Bank[] accounts = new Bank[numberOfCustomers]; for (int i = 0; i < accounts.length; i++) { accounts[i] = new Bank(); accounts[i].openAccount(); } // Run loop until menu 5 is not pressed int choice; do { System.out.println("\nMain Menu"); System.out.println("1. Display All Accounts"); System.out.println("2. Search By Account Number"); System.out.println("3. Deposit Money"); System.out.println("4. Withdraw Money"); System.out.println("5. Exit"); System.out.print("Your Choice: "); choice = scanner.nextInt(); switch (choice) { case 1: for (int i = 0; i < accounts.length; i++) { accounts[i].showAccount(); } break; case 2: System.out.print("Enter Account Number You Want to Search: "); String accountNumberToSearch = scanner.next(); boolean found = false; for (int i = 0; i < accounts.length; i++) { found = accounts[i].search(accountNumberToSearch); if (found) { break; } } if (!found) { System.out.println("Search Failed..Account Not Found.."); } break; case 3: System.out.print("Enter Account Number to Deposit: "); String accountNumberToDeposit = scanner.next(); found = false; for (int i = 0; i < accounts.length; i++) { found = accounts[i].search(accountNumberToDeposit); if (found) { accounts[i].deposit(); break; } } if (!found) { System.out.println("Search Failed..Account Not Found.."); } break; case 4: System.out.print("Enter Account Number to Withdraw: "); String accountNumberToWithdraw = scanner.next(); found = false; for (int i = 0; i < accounts.length; i++) { found = accounts[i].search(accountNumberToWithdraw); if (found) { accounts[i].withdrawal(); break; } } if (!found) { System.out.println("Search Failed..Account Not Found.."); } break; case 5: System.out.println("Good Bye.."); break; default: System.out.println("Invalid Choice.."); } } while (choice != 5); scanner.close(); } }
Submitted by Ayush Gupta (Ayush07)
Download packets of source code on Coders Packet
Comments