Hey guys i have been told to do this Bank account program as you can see the description below, what i have so far is a program that i can create the bank accounts and delete them within the Frame, what i cant get working is the withdrawing the balance when i click the button it don't seem to work and and also what i cant do is the statement and the transactions of each month its really killing me, I am new to all the java programming world if you guys can check my program and see were im going wrong an what is missing i would be truly grateful

*****************************************************************************************

Design and implement an object-oriented program describing two kinds of bank
accounts, FixedFee and ChargeableFee, that differ in the way that fees are charged:
• FixedFee: There is a fixed £5.00 fee at the end of the each month
• ChargeableFee: Each withdrawal costs £0.50. The total fee is calculated and
charged at the end of the month.
The goal for the problem is to use inheritance so as to avoid duplicating code between
the two kinds of account class. This can be done by arranging them in a hierarchy
below a common abstract account class.
Besides designing and implementing the account classes, you should create two
further classes containing main() methods. One of these should be an interactive
application program acting like a Bank, that allows the user to open an account,
deposit and withdraw cash and see the monthly statement. User interaction can take
place on the console, or via pop up windows. The other class should be a noninteractive
test class that checks the functionality of the account classes.
Both kinds of account class should store the current balance and contain the following
methods.
• constructor(initial Balance) creates a new account.
• deposit(amount) adds amount to the balance.
• withdraw(amount) subtracts the amount from the balance.
• endMonth() this method will be called once a month. It should levy any
monthly fee at that time and print out the monthly bank account statement.
The ChargeableFee account will also need to store a running total of the number of
transactions and the methods will have to update this appropriately.
Your solution should comprise the following.
1. Analysis and Design: (i) a class diagram outlining the class structure for your
proposed solution. (ii) a set of summary tables describing the fields,
constructors and methods for each class you intend to create.
2. Implementation: A print out of the Java source code of your complete program.
That is - each of the account classes, the application class and the test class.
3. Test Results: A print out of the output from your test program with evidence of
data validation. Also a set of proposed test cases presented in tabular format.

**************************************************************************************

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

	public class BankAccount extends JFrame {

	    /**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		// Make these variables publicly available
	    public static String Name;
	    public static int Accountnum;
	    public static int Balance;
	    private static final String EMPTY = "EMPTY";

	    // Setup Arrays for each account
	    public static String[] account1 = new String[3];
	    public static String[] account2 = new String[3];
	    public static String[] account3 = new String[3];
	    public static String[] account4 = new String[3];
	    public static String[] account5 = new String[3];
	    public static String[] account6 = new String[3];
	    public static String[] account7 = new String[3];
	    public static String[] account8 = new String[3];
	    public static String[] account9 = new String[3];
	    public static String[] account10 = new String[3];

	    // JPanel for user inputs
	    private JPanel inputDetailJPanel;

	    // JLabel and JTextField for account name
	    private JLabel NameJLabel;
	    private JTextField NameJTextField;

	    // JLabel and JTextField for account number
	    private JLabel AccountnumJLabel;
	    private JTextField AccountnumJTextField;

	    // JLabel and JTextField for balance
	    private JLabel BalanceJLabel;
	    private JTextField BalanceJTextField;


	    // JLabel and JTextField for Withdraw
	    private JLabel WithdrawJLabel;
	    private JTextField WithdrawJTextField;

	    // JButton to create account
	    private JButton CreateAccountJButton;

	    // JButton to delete account
	    private JButton DeleteAccountJButton;

	    // JButton to make transaction
	    private JButton TransactionJButton;

	    // JLabel and JTextArea to display account details
	    private JLabel displayJLabel;
	    private JTextArea displayJTextArea;

	    // initialize number of students to zero
	    private int BankCount = 0;

	    // constants
	    private final int Details = 3;
	    private final int MaxAccounts = 10;
	    private final int FIRST = 0;
	    private final int SECOND = 1;
	    private final int THIRD = 2;

	    // one-dimensional array to store Account names
	    private String AccountNames[] = new String[MaxAccounts];

	    // two-dimensional array to store Account details
	    private int Account[][] = new int[MaxAccounts][Details];

	    // constructor
	    public BankAccount() {
	        createUserInterface();
	    }

	    // create and position GUI components; register event handlers
	    private void createUserInterface() {
	        // get content pane for attaching GUI components
	        Container contentPane = getContentPane();

	        // enable explicit positioning of GUI components
	        contentPane.setLayout(null);

	        // set up inputDetailJPanel
	        inputDetailJPanel = new JPanel();
	        inputDetailJPanel.setBounds(16, 16, 208, 218);
	        inputDetailJPanel.setBorder(new TitledBorder("Input Details"));
	        inputDetailJPanel.setLayout(null);
	        contentPane.add(inputDetailJPanel);

	        // set up NameJLabel
	        NameJLabel = new JLabel();
	        NameJLabel.setBounds(8, 32, 90, 23);
	        NameJLabel.setText("Name:");
	        inputDetailJPanel.add(NameJLabel);

	        // set up NameJTextField
	        NameJTextField = new JTextField();
	        NameJTextField.setBounds(104, 32, 88, 21);
	        NameJTextField.setHorizontalAlignment(JTextField.RIGHT);
	        inputDetailJPanel.add(NameJTextField);

	        // set up AccountnumJLabel
	        AccountnumJLabel = new JLabel();
	        AccountnumJLabel.setBounds(8, 56, 100, 23);
	        AccountnumJLabel.setText("Account Number:");
	        inputDetailJPanel.add(AccountnumJLabel);

	        // set up AccountnumTextField
	        AccountnumJTextField = new JTextField();
	        AccountnumJTextField.setBounds(112, 56, 80, 21);
	        AccountnumJTextField.setHorizontalAlignment(JTextField.RIGHT);
	        inputDetailJPanel.add(AccountnumJTextField);

	        // set up BalanceJLabel
	        BalanceJLabel = new JLabel();
	        BalanceJLabel.setBounds(8, 80, 60, 23);
	        BalanceJLabel.setText("Balance:");
	        inputDetailJPanel.add(BalanceJLabel);

	        // set up BalanceTextField
	        BalanceJTextField = new JTextField();
	        BalanceJTextField.setBounds(112, 80, 80, 21);
	        BalanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
	        inputDetailJPanel.add(BalanceJTextField);


	        // set up WithdrawJLabel
	        WithdrawJLabel = new JLabel();
	        WithdrawJLabel.setBounds(8, 128, 60, 23);
	        WithdrawJLabel.setText("Withdraw:");
	        inputDetailJPanel.add(WithdrawJLabel);

	        // set up WithdrawJTextField
	        WithdrawJTextField = new JTextField();
	        WithdrawJTextField.setBounds(112, 128, 80, 21);
	        WithdrawJTextField.setHorizontalAlignment(JTextField.RIGHT);
	        inputDetailJPanel.add(WithdrawJTextField);

	        // set up CreateAccountButton
	        CreateAccountJButton = new JButton();
	        CreateAccountJButton.setBounds(112, 152, 80, 24);
	        CreateAccountJButton.setText("Create");
	        inputDetailJPanel.add(CreateAccountJButton);
	        CreateAccountJButton.addActionListener(

	        new ActionListener() {
	            // event handler called when CreateAccountJButton
	            // is clicked
	            public void actionPerformed(ActionEvent event) {
	                CreateAccountJButtonActionPerformed(event);
	            }

	        }

	        ); // end call to addActionListener

	        // set up DeleteAccountButton
	        DeleteAccountJButton = new JButton();
	        DeleteAccountJButton.setBounds(16, 152, 80, 24);
	        DeleteAccountJButton.setText("Delete");
	        inputDetailJPanel.add(DeleteAccountJButton);
	        DeleteAccountJButton.addActionListener(

	        new ActionListener() // anonymous inner class
	                {
	                    // event handler called when DeleteAccountJButton
	                    // is clicked
	                    public void actionPerformed(ActionEvent event) {
	                        DeleteAccountJButtonActionPerformed(event);

	                    }

	                }

	                ); // end call to addActionListener

	        // set up TransactionJButton
	        TransactionJButton = new JButton();
	        TransactionJButton.setBounds(16, 180, 176, 24);
	        TransactionJButton.setText("Make Transaction");
	        inputDetailJPanel.add(TransactionJButton);
	        TransactionJButton.addActionListener(

	        new ActionListener() // anonymous inner class
	                {
	                    // event handler called when TransactionJButton
	                    // is clicked
	                    public void actionPerformed(ActionEvent event) {
	                        TransactionJButtonActionPerformed(event);
	                    }

	                } // end anonymous inner class

	                ); // end call to addActionListener

	        // set up displayJLabel
	        displayJLabel = new JLabel();
	        displayJLabel.setBounds(240, 16, 150, 23);
	        displayJLabel.setText("Account Details:");
	        contentPane.add(displayJLabel);

	        // set up displayJTextArea
	        displayJTextArea = new JTextArea();
	        displayJTextArea.setBounds(240, 48, 402, 184);
	        displayJTextArea.setEditable(false);
	        contentPane.add(displayJTextArea);

	        // set properties of application's window
	        setTitle("Bank Accounts"); // set title bar string
	        setSize(670, 308); // set window size
	        setVisible(true); // display window

	    } // end method createUserInterface

	    private void CreateAccountJButtonActionPerformed(ActionEvent event) {
	        // System.out.println("Create Account Button Clicked");
	        Name = NameJTextField.getText();
	        Accountnum = Integer.parseInt(AccountnumJTextField.getText());
	        Balance = Integer.parseInt(BalanceJTextField.getText());

	        displayJTextArea.setText(Name + " " + Accountnum + " " + Balance);

	        // Check to see if each account array is populated and
	        // if not add account details
	        if (account1[0] == EMPTY) {
	            account1[0] = Name;
	            account1[1] = Integer.toString(Accountnum);
	            account1[2] = Integer.toString(Balance);
	            System.out.println("Account 1 Created");
	        } else if (account2[0] == EMPTY) {
	            account2[0] = Name;
	            account2[1] = Integer.toString(Accountnum);
	            account2[2] = Integer.toString(Balance);
	            System.out.println("Account 2 Created");
	        } else if (account3[0] == EMPTY) {
	            account3[0] = Name;
	            account3[1] = Integer.toString(Accountnum);
	            account3[2] = Integer.toString(Balance);
	            System.out.println("Account 3 Created");
	        } else if (account4[0] == EMPTY) {
	            account4[0] = Name;
	            account4[1] = Integer.toString(Accountnum);
	            account4[2] = Integer.toString(Balance);
	            System.out.println("Account 4 Created");
	        } else if (account5[0] == EMPTY) {
	            account5[0] = Name;
	            account5[1] = Integer.toString(Accountnum);
	            account5[2] = Integer.toString(Balance);
	            System.out.println("Account 5 Created");
	        } else if (account6[0] == EMPTY) {
	            account6[0] = Name;
	            account6[1] = Integer.toString(Accountnum);
	            account6[2] = Integer.toString(Balance);
	            System.out.println("Account 6 Created");
	        } else if (account7[0] == EMPTY) {
	            account7[0] = Name;
	            account7[1] = Integer.toString(Accountnum);
	            account7[2] = Integer.toString(Balance);
	            System.out.println("Account 7 Created");
	        } else if (account8[0] == EMPTY) {
	            account8[0] = Name;
	            account8[1] = Integer.toString(Accountnum);
	            account8[2] = Integer.toString(Balance);
	            System.out.println("Account 8 Created");
	        } else if (account9[0] == EMPTY) {
	            account9[0] = Name;
	            account9[1] = Integer.toString(Accountnum);
	            account9[2] = Integer.toString(Balance);
	            System.out.println("Account 9 Created");
	        } else if (account10[0] == EMPTY) {
	            account10[0] = Name;
	            account10[1] = Integer.toString(Accountnum);
	            account10[2] = Integer.toString(Balance);
	            System.out.println("Account 10 Created");

	            // Once account 10 is created. All accounts full.
	            System.out.println("All Accounts Full!");
	            // disable CreateAccountsJButton
	            CreateAccountJButton.setEnabled(false);
	        }

	        // This is just an example so show the arrays are populated...
	        displayJTextArea.setText("Account 1: " + "\n" + account1[0] + "\n"
	                + account1[1] + "\n" + account1[2] + "\n" + "Account 2: " + "\n"
	                + account2[0] + "\n" + account2[1] + "\n" + account2[2] + "\n"
	                + "Account 3: " + "\n" + account3[0] + "\n" + account3[1]
	                + "\n" + account3[2] + "\n");
	        

	    }

	    private void DeleteAccountJButtonActionPerformed(ActionEvent event) {

	        System.out.println("DELETE BUTTON PRESSED");
	        Name = NameJTextField.getText();
	        System.out.println("Delete Account: " + Name);
	        
	        // Delete accounts which match the account Name
	        if (account1[0].equals(Name)) {
	            Arrays.fill(account1, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account2[0].equals(Name)) {
	            Arrays.fill(account2, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account3[0].equals(Name)) {
	            Arrays.fill(account3, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account4[0].equals(Name)) {
	            Arrays.fill(account4, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account5[0].equals(Name)) {
	            Arrays.fill(account5, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account6[0].equals(Name)) {
	            Arrays.fill(account6, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account7[0].equals(Name)) {
	            Arrays.fill(account7, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account8[0].equals(Name)) {
	            Arrays.fill(account8, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account9[0].equals(Name)) {
	            Arrays.fill(account9, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        } else if (account10[0].equals(Name)) {
	            Arrays.fill(account10, EMPTY);
	            displayJTextArea.setText(Name + " Account Deleted.");

	        }

	        
	        // clear JTextFields for new data
	        
	        //NameJTextField.setText("");
	        //AccountnumJTextField.setText("");
	        //BalanceJTextField.setText("");
	        //LodgeJTextField.setText("");
	        //WithdrawJTextField.setText("");
	        
	    }
	    

	    private void TransactionJButtonActionPerformed(ActionEvent event) {
	        // get user input
	        int Accountnum = Integer.parseInt(AccountnumJTextField.getText());
	        

	       

	        // clear other JTextFields for new data
	        NameJTextField.setText("");
	        AccountnumJTextField.setText("");
	        BalanceJTextField.setText("");
	      
	        WithdrawJTextField.setText("");

	        // if no Accounts have been entered
	        if (BankCount < 1) {
	            // disable TransactionJButton
	            TransactionJButton.setEnabled(false);
	        }

	    }

	    private void display() {
	        // add a header to displayJTextArea
	        displayJTextArea
	                .setText("Name\tAccount No.\tLodge\tWithdraw\tBalance\n");

	        /*
	         * for ( int account = 0; account < BankCount; account++ ) { // display
	         * names displayJTextArea.append( Name[ account ] + "\t" ); }
	         */

	    }

	    public static void main(String[] args) {
	        // Populate arrays with the word EMPTY
	        // so we can check to see if the values are empty later
	        Arrays.fill(account1, EMPTY);
	        Arrays.fill(account2, EMPTY);
	        Arrays.fill(account3, EMPTY);
	        Arrays.fill(account4, EMPTY);
	        Arrays.fill(account5, EMPTY);
	        Arrays.fill(account6, EMPTY);
	        Arrays.fill(account7, EMPTY);
	        Arrays.fill(account8, EMPTY);
	        Arrays.fill(account9, EMPTY);
	        Arrays.fill(account10, EMPTY);

	        BankAccount application = new BankAccount();
	        application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	    }

	}

You use BankCount in line 385 to disable transaction button if its value is less than 1, but you never increase the value anywhere in your code while its initial value is 0.

You need to add your own code to do the transaction (in this case it is subtraction) to the correct account number right below line 372. Don't know whether or not you need to handle the exception thrown when the account number is empty.

This code is really spaghetti liked... Not a well-constructed code at all...

well as i said im new to this and really need help as my deadline is on thursday sooo if some 1 can help me with the coding i will be really greatful

I understand, and that's why this assignment is for you to learn. I have already pointed out which line you need to do. That's all you need to do. I doubt that someone would want to complete your assignment for you because you would not learn anything; besides, why would you wait until now to ask???

well because i tried to do it first an now i am stuck really here is my code that work only in command prompt, any way how would i apply that to my fram ?
Here is the code that works without JFrame i still haven't got the monthly statement and the chargeable fee, my dead line is on Thursday an i just recently discovered the site its been really help full an really would be grateful if some one can help me finish this code Java is totally different world to me, I have been up 2 night well 3 with this night trying to understand it now i am completely lost i don't know what it all means any more

import java.util.*;

class BankAccount1 {
        static Scanner input = new Scanner(System.in);
        String name, actype;
        int accNo, bal, amt;

        BankAccount1(String name, int accNo, String actype, int bal) {
                this.name = name;
                this.accNo = accNo;
                this.actype = actype;
                this.bal = bal;
        }

        int deposit() {
                System.out.print("Enter amount to deposit:");
                amt = input.nextInt();
                if (amt < 0) {
                        System.out.println("Invalid Amount");
                        return 1;
                }
                bal = bal + amt;
                return 0;
        }

        int withdraw() {
                System.out.println("Your Balance=" + bal);
                System.out.print("Enter amount to withdraw:");
                amt = input.nextInt();
                if (bal < amt) {
                        System.out.println("Not sufficient balance.");
                        return 1;
                }
                if (amt < 0) {
                        System.out.println("Invalid Amount");
                        return 1;
                }
                bal = bal - amt;
                return 0;
        }

        void display() {
                System.out.println("Name:" + name);
                System.out.println("Account No:" + accNo);
                System.out.println("Balance:" + bal);

        }

        void dbal() {
                System.out.println("Balance:" + bal);
        }

        public static void main(String args[]) {
                System.out.println("Enter your Name: ");
                String nn = input.nextLine();
                System.out.println("Enter Account Number: ");
                int num = input.nextInt();
                System.out.println("Enter Account Type: ");
                String type = input.next();
                System.out.println("Enter Initial Balance: ");
                int bal = input.nextInt();
                BankAccount1 b1 = new BankAccount1(nn, num, type, bal);
                int menu;
                System.out.println("Menu");
                System.out.println("1. Deposit Amount");
                System.out.println("2. Withdraw Amount");
                System.out.println("3. Display Information");
                System.out.println("4. Exit");
                boolean quit = false;
                do {
                        System.out.print("Please enter your choice: ");
                        menu = input.nextInt();
                        switch (menu) {
                        case 1:
                                b1.deposit();
                                break;

                        case 2:
                                b1.withdraw();
                                break;

                        case 3:
                                b1.display();
                                break;

                        case 4:
                                quit = true;
                                break;
                        }
                } while (!quit);
        }
}

Your original code for GUI is poorly constructed! You are supposed to create another class (could be named Account) and use it in this GUI class! I am not going to fix the structure of the code... I did some modification to make it works the way I think it is supposed to work. I know that there are some features missing still. Anyway I do not take any responsibility on my sample code below.

import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.TitledBorder;

// Ugly code with tons of hard-coded portion!!!
// Is this from an IT class???
public class BankAccount extends JFrame {
  /**
  * 
  */
  private static final long serialVersionUID = 1L;
  // Make these variables publicly available
  public static String Name;
  public static int Accountnum;
  public static int Balance;
  private static final String EMPTY = "EMPTY";

  // Setup Arrays for each account !!! hard-coded !!!
  public static String[] account1 = new String[3];
  public static String[] account2 = new String[3];
  public static String[] account3 = new String[3];
  public static String[] account4 = new String[3];
  public static String[] account5 = new String[3];
  public static String[] account6 = new String[3];
  public static String[] account7 = new String[3];
  public static String[] account8 = new String[3];
  public static String[] account9 = new String[3];
  public static String[] account10 = new String[3];

  // JPanel for user inputs
  private JPanel inputDetailJPanel;

  // JLabel and JTextField for account name
  private JLabel NameJLabel;
  private JTextField NameJTextField;

  // JLabel and JTextField for account number
  private JLabel AccountnumJLabel;
  private JTextField AccountnumJTextField;

  // JLabel and JTextField for balance
  private JLabel BalanceJLabel;
  private JTextField BalanceJTextField;

  // JLabel and JTextField for Withdraw
  private JLabel WithdrawJLabel;
  private JTextField WithdrawJTextField;

  // JButton to create account
  private JButton CreateAccountJButton;

  // JButton to delete account
  private JButton DeleteAccountJButton;

  // JButton to make transaction
  private JButton TransactionJButton;

  // JLabel and JTextArea to display account details
  private JLabel displayJLabel;
  private JTextArea displayJTextArea;

  // initialize number of students to zero
  private int BankCount = 0;

  // constants
  private final int Details = 3;
  private final int MaxAccounts = 10;
  private final int FIRST = 0;
  private final int SECOND = 1;
  private final int THIRD = 2;

  // one-dimensional array to store Account names
  private String AccountNames[] = new String[MaxAccounts];

  // two-dimensional array to store Account details
  private int Account[][] = new int[MaxAccounts][Details];

  // constructor
  public BankAccount() {
    createUserInterface();
  }

  // create and position GUI components; register event handlers
  private void createUserInterface() {
    // get content pane for attaching GUI components
    Container contentPane = getContentPane();

    // enable explicit positioning of GUI components
    contentPane.setLayout(null);

    // set up inputDetailJPanel
    inputDetailJPanel = new JPanel();
    inputDetailJPanel.setBounds(16, 16, 208, 218);
    inputDetailJPanel.setBorder(new TitledBorder("Input Details"));
    inputDetailJPanel.setLayout(null);
    contentPane.add(inputDetailJPanel);

    // set up NameJLabel
    NameJLabel = new JLabel();
    NameJLabel.setBounds(8, 32, 90, 23);
    NameJLabel.setText("Name:");
    inputDetailJPanel.add(NameJLabel);

    // set up NameJTextField
    NameJTextField = new JTextField();
    NameJTextField.setBounds(104, 32, 88, 21);
    NameJTextField.setHorizontalAlignment(JTextField.RIGHT);
    inputDetailJPanel.add(NameJTextField);

    // set up AccountnumJLabel
    AccountnumJLabel = new JLabel();
    AccountnumJLabel.setBounds(8, 56, 100, 23);
    AccountnumJLabel.setText("Account Number:");
    inputDetailJPanel.add(AccountnumJLabel);

    // set up AccountnumTextField
    AccountnumJTextField = new JTextField();
    AccountnumJTextField.setBounds(112, 56, 80, 21);
    AccountnumJTextField.setHorizontalAlignment(JTextField.RIGHT);
    inputDetailJPanel.add(AccountnumJTextField);

    // set up BalanceJLabel
    BalanceJLabel = new JLabel();
    BalanceJLabel.setBounds(8, 80, 60, 23);
    BalanceJLabel.setText("Balance:");
    inputDetailJPanel.add(BalanceJLabel);

    // set up BalanceTextField
    BalanceJTextField = new JTextField();
    BalanceJTextField.setBounds(112, 80, 80, 21);
    BalanceJTextField.setHorizontalAlignment(JTextField.RIGHT);
    inputDetailJPanel.add(BalanceJTextField);

    // set up WithdrawJLabel
    WithdrawJLabel = new JLabel();
    WithdrawJLabel.setBounds(8, 128, 60, 23);
    WithdrawJLabel.setText("Withdraw:");
    inputDetailJPanel.add(WithdrawJLabel);

    // set up WithdrawJTextField
    WithdrawJTextField = new JTextField();
    WithdrawJTextField.setBounds(112, 128, 80, 21);
    WithdrawJTextField.setHorizontalAlignment(JTextField.RIGHT);
    inputDetailJPanel.add(WithdrawJTextField);

    // set up CreateAccountButton
    CreateAccountJButton = new JButton();
    CreateAccountJButton.setBounds(112, 152, 80, 24);
    CreateAccountJButton.setText("Create");
    inputDetailJPanel.add(CreateAccountJButton);
    CreateAccountJButton.addActionListener(
      new ActionListener() {
        // event handler called when CreateAccountJButton
        // is clicked
        public void actionPerformed(ActionEvent event) {
            CreateAccountJButtonActionPerformed(event);
        }
      }
    ); // end call to addActionListener

    // set up DeleteAccountButton
    DeleteAccountJButton = new JButton();
    DeleteAccountJButton.setBounds(16, 152, 80, 24);
    DeleteAccountJButton.setText("Delete");
    inputDetailJPanel.add(DeleteAccountJButton);
    DeleteAccountJButton.addActionListener(
      new ActionListener() { // anonymous inner class
        // event handler called when DeleteAccountJButton
        // is clicked
        public void actionPerformed(ActionEvent event) {
            DeleteAccountJButtonActionPerformed(event);

        }
      }
    ); // end call to addActionListener

    // set up TransactionJButton
    TransactionJButton = new JButton();
    TransactionJButton.setBounds(16, 180, 176, 24);
    TransactionJButton.setText("Make Transaction");
    TransactionJButton.setEnabled(false);
    inputDetailJPanel.add(TransactionJButton);
    TransactionJButton.addActionListener(
      new ActionListener() { // anonymous inner class
        // event handler called when TransactionJButton
        // is clicked
        public void actionPerformed(ActionEvent event) {
            TransactionJButtonActionPerformed(event);
        }
      } // end anonymous inner class
    ); // end call to addActionListener

    // set up displayJLabel
    displayJLabel = new JLabel();
    displayJLabel.setBounds(240, 16, 150, 23);
    displayJLabel.setText("Account Details:");
    contentPane.add(displayJLabel);

    // set up displayJTextArea
    displayJTextArea = new JTextArea();
    displayJTextArea.setBounds(240, 48, 402, 184);
    displayJTextArea.setEditable(false);
    contentPane.add(displayJTextArea);

    // set properties of application's window
    setTitle("Bank Accounts"); // set title bar string
    setSize(670, 308); // set window size
    setVisible(true); // display window
  } // end method createUserInterface

  // There are issues with this creation.
  // 1)The account variables are separated and can't check without hard-coded
  // 2)The creation allows empty account name
  private void CreateAccountJButtonActionPerformed(ActionEvent event) {
    // System.out.println("Create Account Button Clicked");
    Name = NameJTextField.getText();
    Accountnum = Integer.parseInt(AccountnumJTextField.getText());
    Balance = Integer.parseInt(BalanceJTextField.getText());

    displayJTextArea.setText(Name + " " + Accountnum + " " + Balance);

    // Check to see if each account array is populated and
    // if not add account details
    int accNum = -1;
    if (account1[0] == EMPTY) {
      account1[0] = Name;
      account1[1] = Integer.toString(Accountnum);
      account1[2] = Integer.toString(Balance);
      accNum = 1;
      BankCount++;  // a bank account is created
      System.out.println("Account 1 Created ("+Name+":"+Accountnum+")");
    } else if (account2[0] == EMPTY) {
      account2[0] = Name;
      account2[1] = Integer.toString(Accountnum);
      account2[2] = Integer.toString(Balance);
      accNum = 2;
      BankCount++;  // a bank account is created
      System.out.println("Account 2 Created ("+Name+":"+Accountnum+")");
    } else if (account3[0] == EMPTY) {
      account3[0] = Name;
      account3[1] = Integer.toString(Accountnum);
      account3[2] = Integer.toString(Balance);
      accNum = 3;
      BankCount++;  // a bank account is created
      System.out.println("Account 3 Created ("+Name+":"+Accountnum+")");
    } else if (account4[0] == EMPTY) {
      account4[0] = Name;
      account4[1] = Integer.toString(Accountnum);
      account4[2] = Integer.toString(Balance);
      accNum = 4;
      BankCount++;  // a bank account is created
      System.out.println("Account 4 Created ("+Name+":"+Accountnum+")");
    } else if (account5[0] == EMPTY) {
      account5[0] = Name;
      account5[1] = Integer.toString(Accountnum);
      account5[2] = Integer.toString(Balance);
      accNum = 5;
      BankCount++;  // a bank account is created
      System.out.println("Account 5 Created ("+Name+":"+Accountnum+")");
    } else if (account6[0] == EMPTY) {
      account6[0] = Name;
      account6[1] = Integer.toString(Accountnum);
      account6[2] = Integer.toString(Balance);
      accNum = 6;
      BankCount++;  // a bank account is created
      System.out.println("Account 6 Created ("+Name+":"+Accountnum+")");
    } else if (account7[0] == EMPTY) {
      account7[0] = Name;
      account7[1] = Integer.toString(Accountnum);
      account7[2] = Integer.toString(Balance);
      accNum = 7;
      BankCount++;  // a bank account is created
      System.out.println("Account 7 Created ("+Name+":"+Accountnum+")");
    } else if (account8[0] == EMPTY) {
      account8[0] = Name;
      account8[1] = Integer.toString(Accountnum);
      account8[2] = Integer.toString(Balance);
      accNum = 8;
      BankCount++;  // a bank account is created
      System.out.println("Account 8 Created ("+Name+":"+Accountnum+")");
    } else if (account9[0] == EMPTY) {
      account9[0] = Name;
      account9[1] = Integer.toString(Accountnum);
      account9[2] = Integer.toString(Balance);
      accNum = 9;
      BankCount++;  // a bank account is created
      System.out.println("Account 9 Created ("+Name+":"+Accountnum+")");
    }
    else if (account10[0] == EMPTY) {
      account10[0] = Name;
      account10[1] = Integer.toString(Accountnum);
      account10[2] = Integer.toString(Balance);
      accNum = 10;
      BankCount++;  // a bank account is created
      System.out.println("Account 10 Created ("+Name+":"+Accountnum+")");

      // Once account 10 is created. All accounts full.
      System.out.println("All Accounts Full!");
      // disable CreateAccountsJButton
      CreateAccountJButton.setEnabled(false);
    }

    // This is just an example so show the arrays are populated...
    display(accNum);
/*    displayJTextArea.setText("Account 1: " + "\n" + account1[0] + "\n"
            + account1[1] + "\n" + account1[2] + "\n" + "Account 2: " + "\n"
            + account2[0] + "\n" + account2[1] + "\n" + account2[2] + "\n"
            + "Account 3: " + "\n" + account3[0] + "\n" + account3[1]
            + "\n" + account3[2] + "\n"); */
    // if no Accounts have been entered
    if (BankCount > 0) {
      // disable TransactionJButton
      TransactionJButton.setEnabled(true);
    }

  }

  // This will create a problem when an empty Name is entered
  // because the program allows empty name account creation!
  // Also, using 'name' to delete does not make sense!
  // People's names are not unique. Should have used account number!!!
  private void DeleteAccountJButtonActionPerformed(ActionEvent event) {
    System.out.println("DELETE BUTTON PRESSED");
    Name = NameJTextField.getText();
    System.out.println("Delete Account: " + Name);

    // Search for the account
    // Delete accounts which match the account Name
    int accNum = -1;
    if (account1[0].equals(Name)) {
      Arrays.fill(account1, EMPTY);
      accNum = 1;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account2[0].equals(Name)) {
      Arrays.fill(account2, EMPTY);
      accNum = 2;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account3[0].equals(Name)) {
      Arrays.fill(account3, EMPTY);
      accNum = 3;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account4[0].equals(Name)) {
      Arrays.fill(account4, EMPTY);
      accNum = 4;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account5[0].equals(Name)) {
      Arrays.fill(account5, EMPTY);
      accNum = 5;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account6[0].equals(Name)) {
      Arrays.fill(account6, EMPTY);
      accNum = 6;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account7[0].equals(Name)) {
      Arrays.fill(account7, EMPTY);
      accNum = 7;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account8[0].equals(Name)) {
      Arrays.fill(account8, EMPTY);
      accNum = 8;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account9[0].equals(Name)) {
      Arrays.fill(account9, EMPTY);
      accNum = 9;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }
    else if (account10[0].equals(Name)) {
      Arrays.fill(account10, EMPTY);
      accNum = 10;
      BankCount--;  // remove it
      displayJTextArea.setText(Name + " Account Deleted ("+Name+")");
    }

    // clear JTextFields for new data
    NameJTextField.setText("");
    AccountnumJTextField.setText("");
    BalanceJTextField.setText("");
    //LodgeJTextField.setText("");
    WithdrawJTextField.setText("");

    display(accNum);

    // if no Accounts have been entered
    if (BankCount < 1) {
      // disable TransactionJButton
      TransactionJButton.setEnabled(false);
    }
  }

  private void TransactionJButtonActionPerformed(ActionEvent event) {
    // get user input
    String Accountnum = AccountnumJTextField.getText();
    int withdrawAmt = Integer.parseInt(WithdrawJTextField.getText());
    int accNum = -1;

    // do transaction here
    if (withdrawAmt>0) {
      // search for the account with the account number
      if (account1[1].equals(Accountnum)) {
        accNum = 1;
        int amt = Integer.parseInt(account1[2]);
        if (amt>=withdrawAmt) {
          account1[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account2[1].equals(Accountnum)) {
        accNum = 2;
        int amt = Integer.parseInt(account2[2]);
        if (amt>=withdrawAmt) {
          account2[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account3[1].equals(Accountnum)) {
        accNum = 3;
        int amt = Integer.parseInt(account3[2]);
        if (amt>=withdrawAmt) {
          account3[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account4[1].equals(Accountnum)) {
        accNum = 4;
        int amt = Integer.parseInt(account4[2]);
        if (amt>=withdrawAmt) {
          account4[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account5[1].equals(Accountnum)) {
        accNum = 5;
        int amt = Integer.parseInt(account5[2]);
        if (amt>=withdrawAmt) {
          account5[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account6[1].equals(Accountnum)) {
        accNum = 6;
        int amt = Integer.parseInt(account6[2]);
        if (amt>=withdrawAmt) {
          account6[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account7[1].equals(Accountnum)) {
        accNum = 7;
        int amt = Integer.parseInt(account7[2]);
        if (amt>=withdrawAmt) {
          account7[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account8[1].equals(Accountnum)) {
        accNum = 8;
        int amt = Integer.parseInt(account8[2]);
        if (amt>=withdrawAmt) {
          account8[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account9[1].equals(Accountnum)) {
        accNum = 9;
        int amt = Integer.parseInt(account9[2]);
        if (amt>=withdrawAmt) {
          account9[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
      else if (account10[1].equals(Accountnum)) {
        accNum = 10;
        int amt = Integer.parseInt(account10[2]);
        if (amt>=withdrawAmt) {
          account10[2] = Integer.toString(amt-withdrawAmt);
        }
        else {
          System.out.println("Cannot withdraw, not enough amount");
        }
      }
    }

    // clear other JTextFields for new data
    NameJTextField.setText("");
    AccountnumJTextField.setText("");
    BalanceJTextField.setText("");
    WithdrawJTextField.setText("");

    display(accNum);
  }

  private void display(int accNum) {
    // add a header to displayJTextArea
    String output = "Name\tAccount No.\tBalance\n";

    /*
     * for ( int account = 0; account < BankCount; account++ ) { // display
     * names displayJTextArea.append( Name[ account ] + "\t" ); }
     * Can't do this because all accounts are separated!!!
     * Therefore, the display is hard-coded!!!
     */
    if (BankCount>0) {  // has some account data
      if (accNum==1 || accNum==0) {
        if (account1[1]!=EMPTY) {
          output += account1[0]+"\t"+account1[1]+"\t"+account1[2]+"\n";
        }
      }
      if (accNum==2 || accNum==0) {
        if (account2[1]!=EMPTY) {
          output += account2[0]+"\t"+account2[1]+"\t"+account2[2]+"\n";
        }
      }
      if (accNum==3 || accNum==0) {
        if (account3[1]!=EMPTY) {
          output += account3[0]+"\t"+account3[1]+"\t"+account3[2]+"\n";
        }
      }
      if (accNum==4 || accNum==0) {
        if (account4[1]!=EMPTY) {
          output += account4[0]+"\t"+account4[1]+"\t"+account4[2]+"\n";
        }
      }
      if (accNum==5 || accNum==0) {
        if (account5[1]!=EMPTY) {
          output += account5[0]+"\t"+account5[1]+"\t"+account5[2]+"\n";
        }
      }
      if (accNum==6 || accNum==0) {
        if (account6[1]!=EMPTY) {
          output += account6[0]+"\t"+account6[1]+"\t"+account6[2]+"\n";
        }
      }
      if (accNum==7 || accNum==0) {
        if (account7[1]!=EMPTY) {
          output += account7[0]+"\t"+account7[1]+"\t"+account7[2]+"\n";
        }
      }
      if (accNum==8 || accNum==0) {
        if (account8[1]!=EMPTY) {
          output += account8[0]+"\t"+account8[1]+"\t"+account8[2]+"\n";
        }
      }
      if (accNum==9 || accNum==0) {
        if (account9[1]!=EMPTY) {
          output += account9[0]+"\t"+account9[1]+"\t"+account9[2]+"\n";
        }
      }
      if (accNum==10 || accNum==0) {
        if (account10[1]!=EMPTY) {
          output += account10[0]+"\t"+account10[1]+"\t"+account10[2]+"\n";
        }
      }
    }

    displayJTextArea.setText(output);
  }

  public static void main(String[] args) {
    // Populate arrays with the word EMPTY
    // so we can check to see if the values are empty later
    Arrays.fill(account1, EMPTY);
    Arrays.fill(account2, EMPTY);
    Arrays.fill(account3, EMPTY);
    Arrays.fill(account4, EMPTY);
    Arrays.fill(account5, EMPTY);
    Arrays.fill(account6, EMPTY);
    Arrays.fill(account7, EMPTY);
    Arrays.fill(account8, EMPTY);
    Arrays.fill(account9, EMPTY);
    Arrays.fill(account10, EMPTY);

    BankAccount application = new BankAccount();
    application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.