Feb 5, 2022

Bank Application Java Program - Java Program Example

Here we can see a java program to create a bank system project for banking work.

Java program for create banking system, this program used we can open Bank account , deposit money and withdraw and check bank balance.


When we compile this program then display a banking menu like this......

1. Open Account
2. Deposit
3. Withdraw
4. Check Balance
5. Close Account
Here  we can choose any option for work banking we can see in details in output.




Program Code 


package com.androidpro.in;



import
java.util.Scanner;
import
java.util.StringTokenizer;

public class
Main {

   
static public int accno=0;
    static public int
amount = 0;
    static public
String name = "";
    public static void
open(String s,int n) {                         // case 1
       
try{
            System.
out.println("Enter Your Name: ");
           
Scanner in1 = new Scanner(System.in);
           
name = in1.nextLine();
           
System.out.println("Enter An Account Number:");
           
Scanner ln=new Scanner(System.in);
            int
accno=in1.nextInt();
           
System.out.println("Enter The Amount To Deposit:");
           
Scanner in=new Scanner(System.in);
            int
a=in1.nextInt();
           
Main.amount=amount+a;
//BankManagementSystem.amount = 0;
           
{
                System.
out.println("__________________________________________");
               
System.out.println("\t\tYour Account Created\n\n");
               
System.out.println("Account name is:   \t" + name );
               
System.out.println("Account Number Is: \t"+accno);
               
System.out.println ("Account balance : \t" + amount);
               
System.out.println("_____________________________________________");}
        }
       
catch(Exception e)
        {System.
out.println ("Error! " + e);}
    }
   
static public void deposit(String s, int n)                        // case 2
   
{
        System.
out.println("Enter An Account Number:");
        
Scanner ln=new Scanner(System.in);
        int
accno=ln.nextInt();
       
System.out.println("Enter The Amount To Deposit: ");
        try
{
            Scanner in1 =
new Scanner(System.in);
            int
a = in1.nextInt();
            if
(name.isEmpty()){
                System.
out.println("\nNo Account Found!! Please Open An Account");
           
}
           
else{
                Main.
amount = amount + a;
               
System.out.println("\nDeposit was sucessfull!!");
               
System.out.println("Account Number Is:"+accno);
               
System.out.println("Current balance = " + amount);
           
}
        }
       
catch(Exception e)
        {System.
out.println ("");}
    }
   
static public void withdraw(String s, int n){                      // case 3
       
System.out.println("Enter An Account Number:");
       
Scanner ln=new Scanner(System.in);
        int
accno=ln.nextInt();
       
System.out.println("Enter The Amount To Be Withdrawn: ");
       
Scanner in1 = new Scanner(System.in);
        int
a = in1.nextInt();
        try
{
           
if(!(name.isEmpty()))
               
if (amount < a){
                    Main.
amount = amount-0;
                   
System.out.println("Out Of Balance, Current Balance = " + amount);}
               
else{
                    Main.
amount = amount -a;
                   
System.out.println("Account Number Is:"+accno);
                   
System.out.println("Transaction Succesful, Current Balance = " + amount);
               
}
           
else{
                System.
out.println("\nNo Account Found!! Please Open An Account");
           
}
        }
       
catch(Exception e)
        {System.
out.println ("Error! " + e);}
    }
   
static public void check(String s,int n){                          // case 4
       
System.out.println("Enter An Account Number:");
       
Scanner ln=new Scanner(System.in);
        int
accno=ln.nextInt();
        if
(name.isEmpty()){
            System.
out.println("\nNo Account Found!! Please Open An Account");
       
}
       
else{
            System.
out.println("Name " + name + " Current Balance = " + Main.amount);
       
}
    }
   
static public void close(String s,int n){             // case 5
       
System.out.println("Enter An Account Number:");
       
Scanner ln=new Scanner(System.in);
        int
accno=ln.nextInt();
        if
(name.isEmpty()){
            System.
out.println("\nNo Account Found!! Please Open An Account");}
       
else{
            Main.
amount = 0;
           
System.out.println("Name " + name + " closed!!!");
           
System.out.println("Account Number Is:"+accno);
           
name = "";
       
}
    }
   
static public void main(String [] args){
        System.
out.println("\t\t\t Learn Banking System");
        
System.out.println("__________________________________________________");
       
System.out.println("\t\t\t\t Menu\n\n");
       
System.out.println("1. Open Account");
       
System.out.println("2. Deposit");
       
System.out.println("3. Withdraw");
       
System.out.println("4. Check Balance");
       
System.out.println("5. Close Account");
       
System.out.println("__________________________________________________");
       
System.out.println("-----------------------");
       
System.out.println("<--Enter your choice-->");
       
System.out.println("-----------------------");
        try
{
            Scanner in =
new Scanner(System.in);
            int
c = in.nextInt();
           
String s = new String();
            int
n=0;
            switch
(c){
               
case 1: open(s,n);
                    break;
                case
2: deposit(s,n);
                    break;
                case
3: withdraw(s,n);
                    break;
                case
4: check(s,n);
                    break;
                case
5: close(s, n);
                    break;
                default
:
                    System.
out.println("Invalid option!!");
                    break;
           
}
            System.
out.println("\nPress 0 to close...");
           
System.out.println("Press any other number(s) to continue...");
           
Scanner in5 = new Scanner(System.in);
            int
r=in5.nextInt();
            if
(!(r==0))
            {
                String[] s2 =
null;
               
System.out.println("");
               
main(s2);}
        }
       
catch(Exception e)
        {System.
out.println ("Error! " + e);
           
String[] d = null;
           
System.out.println("");
           
main(d);}
    }


}



Output 1 Open Bank Account




Learn Banking System
__________________________________________________
                                          Menu


1. Open Account
2. Deposit
3. Withdraw
4. Check Balance
5. Close Account
__________________________________________________
-----------------------
<--Enter your choice-->
-----------------------
1
Enter Your Name:
Ankit Mishra
Enter An Account Number:
5567
Enter The Amount To Deposit:
5000
__________________________________________
                     Your Account Created


Account name is:    Ankit Mishra
Account Number Is:          5567
Account balance :   5000
_____________________________________________

Press 0 to close...
Press any other number(s) to continue...
5

Output 2 Deposit Money From Bank

                                Learn Banking System
__________________________________________________
                                          Menu


1. Open Account
2. Deposit
3. Withdraw
4. Check Balance
5. Close Account
__________________________________________________
-----------------------
<--Enter your choice-->
-----------------------
2
Enter An Account Number:
5567
Enter The Amount To Deposit:
400

Deposit was sucessfull!!
Account Number Is:5567
Current balance = 5400

Press 0 to close...
Press any other number(s) to continue...
7

Output 3 Withdraw Money From Bank

                                Learn Banking System
__________________________________________________
                                          Menu


1. Open Account
2. Deposit
3. Withdraw
4. Check Balance
5. Close Account
__________________________________________________
-----------------------
<--Enter your choice-->
-----------------------
3
Enter An Account Number:
5567
Enter The Amount To Be Withdrawn:
900
Account Number Is:5567
Transaction Succesful, Current Balance = 4500

Press 0 to close...
Press any other number(s) to continue...
6

Output 4 Check Bank Balence

                                Learn Banking System
__________________________________________________
                                          Menu


1. Open Account
2. Deposit
3. Withdraw
4. Check Balance
5. Close Account
__________________________________________________
-----------------------
<--Enter your choice-->
-----------------------
4
Enter An Account Number:
5567
Name Ankit Mishra Current Balance = 4500

Press 0 to close...
Press any other number(s) to continue...
8

Output 5 Close Account Number

                                Learn Banking System
__________________________________________________
                                          Menu


1. Open Account
2. Deposit
3. Withdraw
4. Check Balance
5. Close Account
__________________________________________________
-----------------------
<--Enter your choice-->
-----------------------
5Enter An Account Number:

5567
Name Ankit Mishra closed!!!
Account Number Is:5567

Press 0 to close...
Press any other number(s) to continue...

Share:

0 Comments: