Description of the Program
This Program -Java Program for Bank Management System includes 4 features in the whole program
1, Create Account
2. Account Information
3. Deposit Cash
4. With Drawl Cash
These 4 options are provided for successfully implementation of the program.
You can see also the C Program or Project to implement banking management system
Read More
Steps to Execute the Java Program for Bnak Management System
1. If You are Using NetBeans then First Create a file name XYZBank.Java and Paste the Following file source code into XYZBank.java.
2. Then Create another file named Account.java and paste the following file code into that.
3. Create another file named BankException.java and paste the following file code into that particular file
Souce Code:
XYZBank.java
package xyzbank; import java.util.Scanner; import xyzbank.account.*; import xyzbank.exception.*; public class XYZBank { public static void main(String[] args) { // TODO code application logic here int k=1,choice,ac_no; double balance,amount; Scanner s=new Scanner(System.in); Account a=new Account(); while(k==1) { System.out.println(":::::::::XYZ BANK::::::::::"); System.out.println("1. Create Account"); System.out.println("2. Account Information"); System.out.println("3. Diposit Cash"); System.out.println("4. Withdrawl Cash"); System.out.println("Enter Your Choice:"); choice=s.nextInt(); switch(choice) { case 1: String name,type; System.out.print("Enter Name of Account Holder"); name=s.next(); a.setName(name); System.out.print("Enter Account Number"); ac_no=s.nextInt(); a.SetAccNo(ac_no); System.out.print("Enter Account Type"); type=s.next(); a.SetType(type); System.out.print("Enter Balance"); balance=s.nextDouble(); a.Setblanace(balance); break; case 2: System.out.print("Enter Account No"); ac_no=s.nextInt(); if(ac_no==a.AccNo()){ a.displayAccNo(); a.displayName(); a.displayType(); a.displayBalance(); } else System.out.print("Wrong Account No"); break; case 3: System.out.print("Enter Account No"); ac_no=s.nextInt(); if(ac_no==a.AccNo()) { try{ System.out.print("Enter Amount"); amount=s.nextDouble(); a.deposit(amount); } catch(BankException exp){ System.out.println("Error: "+exp.show()); } } break; case 4: { System.out.print("Enter Account No"); ac_no=s.nextInt(); if(ac_no==a.AccNo()) { try{ System.out.print("Enter Amount"); amount=s.nextDouble(); a.Withdrawl(amount); } catch(BankException exp){ System.out.println("Error: "+exp.show()); } } } break; default: System.out.println("you have enter wrong Input"); } System.out.println("Enter 1 to Continue..."); k=s.nextInt(); } } }
Account.Java
package xyzbank.account; import xyzbank.exception.*; public class Account { public double balance; private String name; private String type; private int acc_no; public void setName(String name){ this.name=name; } public void displayName(){ System.out.print("Name of Account Holder"+name); } public void SetType(String type){ this.type=type; } public void displayType(){ System.out.print("Type of Account "+type); } public void SetAccNo(int acc_no) { this.acc_no=acc_no; } public int AccNo(){ return acc_no; } public void displayAccNo(){ System.out.print(" Account Number "+acc_no); } public void Setblanace(double balance ) { this.balance=balance; } public void displayBalance(){ System.out.print(" Account Balance "+balance); } public void deposit(double amount) throws BankException{ if(amount<=40000) balance=balance+amount; else throw new BankException("Amount shuold be less than ",amount); } public void Withdrawl(double amount) throws BankException{ if(balance>=amount) balance=balance-amount; else throw new BankException("Not Sufficient Balance"); } }
BankException.Java
package xyzbank.exception; public class BankException extends Exception { private String message; public double amount; public BankException() { amount=0; message="Exception"; } public BankException(String message){ this.message=message; } public BankException(String message,double amount){ this.message=message; this.amount=amount; } public String show() { return message; } }
0 comments:
Post a Comment