Add to Favorites    Make Home Page 361 Online  

 Language Categories  
 Our Services  

Home » Java Home » GUI Home » Bank Account Simulation (Mini Project)

A D V E R T I S E M E N T

Search Projects & Source Codes:

Title Bank Account Simulation (Mini Project)
Author chethan M gowda
Author Email chethan842003 [at] yahoo.com
Description This project helps in maintaining and accesing the bank accounts

Category Java » GUI
Hits 137260
Code Select and Copy the Code
Code : /********************************************************** * Program to create GUI for Bank Account Simulation. * ***********************************************************/ import java.awt.*; import java.awt.event.*; import javax.swing.*; class GuiAccTest extends Frame implements ActionListener { Label lab=new Label(" "); Label lab1=new Label(" "); TextField t[]=new TextField [4]; Label l[]=new Label [4]; Button but=new Button("Create Account"); Button but1=new Button("Test Account"); BankAccount b; GuiAccTest() { addWindowListener(new NewWindowAdapter()); setLayout(new GridLayout(2,0)); Panel p=new Panel(); Panel p1=new Panel(); but.addActionListener(this); but1.addActionListener(this); p.setLayout(new GridLayout(5,2)); p1.add(lab1); p1.add(lab); l[0]=new Label("Account Number"); l[1]=new Label("Initial Balance"); l[2]=new Label("Deposit Amount"); l[3]=new Label("Withdraw Amount"); for(int i=0;i<4;i++) { t[i]=new TextField(10); p.add(l[i]); p.add(t[i]); } p.add(but); p.add(but1); but1.setVisible(false); l[2].setVisible(false); l[3].setVisible(false); t[2].setVisible(false); t[3].setVisible(false); add(p); add(p1); } String testAccount(int d_amt,int w_amt) { String msg; b.deposit(d_amt); msg="Transaction Succesful"; try { b.withdraw(w_amt); }catch(FundsInsufficientException fe) { fe=new FundsInsufficientException(b.amount,w_amt); msg=String.valueOf(fe); } return msg; } public void actionPerformed(ActionEvent ae) { String str=ae.getActionCommand(); if(str.equals("Create Account")) { b=new BankAccount(Integer.parseInt(t[0].getText()), Integer.parseInt(t[1].getText())); but1.setVisible(true); l[2].setVisible(true); l[3].setVisible(true); t[2].setVisible(true); t[3].setVisible(true); but.setVisible(false); l[0].setVisible(false); l[1].setVisible(false); t[0].setVisible(false); t[1].setVisible(false); lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount); return; } else { lab.setText(testAccount(Integer.parseInt(t[2].getText()), Integer.parseInt(t[3].getText()))); lab1.setText("Account : "+b.accnum+", Current Balance : "+b.amount); } } public static void main(String arg[]) { GuiAccTest at=new GuiAccTest(); at.setTitle("Bank Account Tester"); at.setSize(600,200); at.setVisible(true); } } class NewWindowAdapter extends WindowAdapter { public void windowClosing(WindowEvent we) { System.exit(0); } } class BankAccount { int accnum; int amount; BankAccount(int num,int amt) { accnum=num; amount=amt; } public void deposit(int amt) { amount=amount+amt; } public void withdraw(int amt) throws FundsInsufficientException { if(amt>amount) throw new FundsInsufficientException(amount,amt); else amount=amount-amt; } } class FundsInsufficientException extends Exception { int balance; int withdraw_amount; FundsInsufficientException(int bal,int w_amt) { balance=bal; withdraw_amount=w_amt; } public String toString() { return "Your withdraw amount ("+withdraw_amount+") is less than the balance ("+balance+"). No withdrawal was recorded."; } }

Related Source Codes

Script Name Author
Sending mail Using JavaMail to Yahoo and Gmail accounts sai prasad
Simple Program in Java to Implement Multithreading Satish.K
Simple Calculator in Java Using Remote Method Invocation Satish.K
Guest Book Application Using Servlets Satish.K
String Manipulation Using Stringification Satish.K
String Manipulation Using Stringification Satish.K
Moving Ball Application Using Java Beans Satish.K
Rapid Roll game subrahmanyeswararao
student mgm arpan
Sourav Datta
Download Manager Sagar
Address Book in Java Rahul Chouhan
address book using java database connectivity(jdbc-msaccess) shekhar bansal
sun Steganography B.Rajavel
Connecting Java with MS-Access - Inserting data in Aseem

A D V E R T I S E M E N T




Google Groups Subscribe to SourceCodesWorld - Techies Talk
Email:


Free eBook - Interview Questions: Get over 1,000 Interview Questions in an eBook for free when you join JobsAssist. Just click on the button below to join JobsAssist and you will immediately receive the Free eBook with thousands of Interview Questions in an ebook when you join.

New! Click here to Add your Code!


ASP Home | C Home | C++ Home | COBOL Home | Java Home | Pascal Home
Source Codes Home Page

 Advertisements  

Google Search

Google

Source Codes World.com is a part of Vyom Network.

Vyom Network : Web Hosting | Dedicated Server | Free SMS, GRE, GMAT, MBA | Online Exams | Freshers Jobs | Software Downloads | Interview Questions | Jobs, Discussions | Placement Papers | Free eBooks | Free eBooks | Free Business Info | Interview Questions | Free Tutorials | Arabic, French, German | IAS Preparation | Jokes, Songs, Fun | Free Classifieds | Free Recipes | Free Downloads | Bangalore Info | Tech Solutions | Project Outsourcing, Web Hosting | GATE Preparation | MBA Preparation | SAP Info | Software Testing | Google Logo Maker | Freshers Jobs

Sitemap | Privacy Policy | Terms and Conditions
Copyright ©2003-2014 SourceCodesWorld.com, All Rights Reserved.
Page URL: http://www.sourcecodesworld.com/source/show.asp?ScriptID=867


Download Yahoo Messenger | Placement Papers | Free SMS | C Interview Questions | C++ Interview Questions | Quick2Host Review