Results 1 to 3 of 3
  1. #1
    zackvenom is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default how to make bank system using java gui....please help me!!

    this code must required:
    A)updates
    B)delete
    C)save
    D)edit

    anyone can help me....pleaseee!!!

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,184
    Rep Power
    19

    Default Re: how to make bank system using java gui....please help me!!

    Recommended reading: all sections of How to ask questions the smart way

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    zackvenom is offline Member
    Join Date
    Mar 2012
    Posts
    2
    Rep Power
    0

    Default Re: how to make bank system using java gui....please help me!!

    --------
    START
    ---------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    import javax.swing.*;

    public class start
    {
    public static void main(String[] args)
    {
    // Welcome message. This is the first thing that they will see when they run the program.
    JOptionPane.showMessageDialog(null, "Welcome to my Mini Bank Simulator.");

    bankGUI initiate = new bankGUI();
    initiate.setDefaultCloseOperation(JFrame.EXIT_ON_C LOSE); // enables the user to close the window (when X is pressed)
    initiate.setSize(800, 480); // setting the width, height of the window
    initiate.setVisible(true); // enabling the window to be visible to the user

    }


    } // END class start


    --------
    BANK GUI
    ---------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    import java.awt.FlowLayout; // arranges components from left-to-right and top-to-bottom
    import java.awt.event.*; // for event handling (i.e. action and listener events)
    import java.awt.*; // for textarea
    import java.util.*; // for vector use
    import javax.swing.*;

    public class bankGUI extends JFrame // enables the use of JFrame (e.g. a window)
    {
    private JButton addAccount;
    private JButton checkAccount;
    private JButton close;
    private TextArea showResult = new TextArea(25,75);
    private String stringOutput = "";

    acc accAdd; // polymorphism

    // the constructor - everything within will be used for the creation of the window
    public bankGUI()
    {
    super("mr x's Bank Simulator"); // creation of the title for the window

    setLayout(new FlowLayout()); // setting the layout - how things are placed within the window

    addAccount = new JButton("Add Account");
    add(addAccount); // creation and addition of buttons & tank background to the window

    checkAccount = new JButton("Check Account");
    add(checkAccount);

    close = new JButton("CLOSE");
    add(close);

    showResult.setEditable(false);
    add(showResult);

    // creation of an object of an action listener
    thehandler handler = new thehandler(); //CHANGE THIS?
    addAccount.addActionListener(handler);
    checkAccount.addActionListener(handler);
    close.addActionListener(handler);

    }


    public class thehandler implements ActionListener // the class to handle the events. This calls on a method when a specific action occurs
    {


    public void actionPerformed(ActionEvent event)
    {
    if (event.getSource()==addAccount)
    {
    String name = JOptionPane.showInputDialog("Please enter your name:");
    String accCreate = JOptionPane.showInputDialog("What type of account would you like to create? (CURRENT / SAVINGS / BUSINESS)");


    if (accCreate.equalsIgnoreCase("CURRENT"))
    {
    try
    {
    String pinNoAsk = JOptionPane.showInputDialog("Please enter a pin for your account:");
    int pinNo = Integer.parseInt(pinNoAsk);
    String depositAsk = JOptionPane.showInputDialog("Please enter amount to deposit into account:");
    double depositAdd = Double.parseDouble(depositAsk);


    currentAcc(accCreate, pinNo, name, depositAdd);


    stringOutput = stringOutput + " "+name + " has created a CURRENT account with a balance of £"+depositAdd+".\n";
    showResult.setText(stringOutput);
    }

    catch (NumberFormatException invalidValue)
    {
    JOptionPane.showMessageDialog(null, "You must enter a numerical value in order to deposit funds");
    }
    //System.out.println(one.getBalance());
    //System.out.println(((accCurrent)one).interestBal() );
    // ((accCurrent)one).interestBal();
    }


    else if (accCreate.equalsIgnoreCase("SAVINGS"))
    {
    try
    {
    String pinNoAsk = JOptionPane.showInputDialog("Please enter a pin for your account:");
    int pinNo = Integer.parseInt(pinNoAsk);
    String depositAsk = JOptionPane.showInputDialog("Please enter amount to deposit into account:");
    double depositAdd = Double.parseDouble(depositAsk);

    accountDetails.storeDetails(accCreate, name, pinNo, depositAdd);

    stringOutput = stringOutput + " "+name + " has created a SAVINGS account with a balance of £"+depositAdd+".\n";
    showResult.setText(stringOutput);
    }

    catch (NumberFormatException invalidValue)
    {
    JOptionPane.showMessageDialog(null, "You must enter a numerical value in order to deposit funds");
    }

    }


    else if (accCreate.equalsIgnoreCase("BUSINESS"))
    {
    try
    {
    String pinNoAsk = JOptionPane.showInputDialog("Please enter a pin for your account:");
    int pinNo = Integer.parseInt(pinNoAsk);
    String depositAsk = JOptionPane.showInputDialog("Please enter amount to deposit into account:");
    double depositAdd = Double.parseDouble(depositAsk);



    stringOutput = stringOutput + " "+name + " has created a BUSINESS account with a balance of £"+depositAdd+".\n";
    showResult.setText(stringOutput);
    }

    catch (NumberFormatException invalidValue)
    {
    JOptionPane.showMessageDialog(null, "You must enter a numerical value in order to deposit funds");
    }

    }

    else
    {
    JOptionPane.showMessageDialog(null, "The only account types available for creation are 'CURRENT', 'SAVINGS' or 'BUSINESS'.");
    }


    }
    ////////////////////////ERRORS LIKELY TO OCCUR FROM HERE (IT SHOULD COMPILE BUT I REALISE THAT I MAY BE DOING THE WRONG THING)


    else if (event.getSource()==checkAccount)
    { // HERE I WOULD ASK THE USER TO ENTER THE TYPE OF ACCOUNT TO CHECK, FOLLOWED BY THEIR PIN. IF THERE IS A MATCH THE NEXT MESSAGE WOULD BE PRINTED, WITH THE ACTIONS SELECTED USING THE VALUES (E.G. BALANCE) BEFORE RETURNING THE VALUES TO BE STORED AGAIN FOR FUTURE USE - AS IF THE USER WAS USING AN ATM MACHINE.
    String checkAsk = JOptionPane.showInputDialog("Which action would you like to perform?\n 1] View Balance\n 2] Withdraw from Account\n 3] Deposit into Account\n 4] View current balance w/ interest\n 5] EXIT"); // add option in future to close account???
    int checkAns = Integer.parseInt(checkAsk);

    if (checkAns == 1) // View Balance
    {
    System.out.println(accAdd.getBalance());
    // stringOutput = stringOutput + accAdd.getBalance()+"\n";
    // showResult.setText(stringOutput);
    }

    else if (checkAns == 2) // Withdraw from Account
    {
    String wdAsk = JOptionPane.showInputDialog("How much would you like to withdraw?");
    double wdAns = Double.parseDouble(wdAsk);

    stringOutput = stringOutput + accAdd.withdraw(wdAns)+"\n";
    showResult.setText(stringOutput);
    }

    else if (checkAns == 3) // Deposit into Account
    {
    String wdAsk = JOptionPane.showInputDialog("How much would you like to deposit?");
    double wdAns = Double.parseDouble(wdAsk);

    stringOutput = stringOutput + accAdd.deposit(wdAns)+"\n";
    showResult.setText(stringOutput);
    }

    else if (checkAns == 4) // View current w/ interest balance
    {
    stringOutput = stringOutput + ((accCurrent)accAdd).interestBal()+"\n";
    showResult.setText(stringOutput);

    }

    else if (checkAns == 5) // EXIT
    {
    JOptionPane.showMessageDialog(null, "Thank you for using our banking system.");
    }

    else
    {
    JOptionPane.showMessageDialog(null, "You must enter a value between 1 and 4.");
    }


    }
    // THIS IS FINE

    else if (event.getSource()==close)
    {
    int closeAsk = JOptionPane.showConfirmDialog(null, "Quit program?", "CLOSE", JOptionPane.YES_NO_OPTION);

    if(closeAsk == JOptionPane.YES_OPTION)
    {
    JOptionPane.showMessageDialog(null, "Thank you for using this program.");
    System.exit(0);
    }



    }


    }
    }


    }

    --------
    acc (ACCOUNT)
    ---------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    public class acc
    {
    protected String name;
    protected double balance = 0;

    public acc(String n, double depAcc)
    {
    name = n;
    balance = depAcc;
    }

    public double getBalance()
    {
    return balance;
    }

    public double withdraw(double wdAcc)
    {
    balance -= wdAcc;
    return balance;
    }

    public double deposit(double depAcc)
    {
    balance += depAcc;
    return balance;
    }

    }


    --------
    accCURRENT (CURRENT ACCOUNT - subclass of acc)
    ---------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    public class accCurrent extends acc
    {
    private double interestRate = 5.2;
    private double finalBal;

    // constructor - cus it has same name as class & is run everytime an object is created
    public accCurrent(String n, double depAcc)
    {
    super(n, depAcc);
    finalBal = depAcc;
    }

    // calculating the interest rate balance
    public double interestBal ()
    {
    double intApplyC = (finalBal / 100) * interestRate;
    double intApplyF = finalBal + intApplyC;

    return intApplyF;
    }

    }


    --------
    accSAVINGS (SAVINGS ACCOUNT - subclass of acc)
    ---------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    public class accSavings extends acc
    {
    private double interestRate = 9;
    private double finalBal;

    // constructor - cus it has same name as class & is run everytime an object is created
    public accSavings(String n, double depAcc)
    {
    super(n, depAcc);
    finalBal = depAcc;
    }

    // calculating the interest rate balance
    public double interestBal (double finalBal, double interestRate)
    {
    double intApplyC = (finalBal / 100) * interestRate;
    double intApplyF = finalBal + intApplyC;

    return intApplyF;
    }

    }


    --------
    accBUSINESS (BUSINESS ACCOUNT - subclass of acc)
    ---------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    public class accBusiness extends acc
    {
    private double interestRate = 12.6;
    private double finalBal;

    // constructor - cus it has same name as class & is run everytime an object is created
    public accBusiness(String n, double depAcc)
    {
    super(n, depAcc);
    finalBal = depAcc;
    }

    // calculating the interest rate balance
    public double interestBal (double finalBal, double interestRate)
    {
    double intApplyC = (finalBal / 100) * interestRate;
    double intApplyF = finalBal + intApplyC;

    return intApplyF;
    }

    }
    I've attempted to store the values in a new class, where the vectors would be placed ("accountDetails" as you can see in the pic with the red cross), but ended up getting errors including one along the lines of "calling non-static method in static method in Java".

    If of any interest I can post the code but it's not currently in use:

    _-------------------
    accountDetails
    ------------
    Java Code:
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    import java.util.*;

    public class accountDetails extends acc
    {
    Vector currentIDNo = new Vector(); // make private???
    Vector curentNames = new Vector();
    Vector currentBalance = new Vector();


    Vector savingsIDNo = new Vector();
    Vector savingsNames = new Vector();
    Vector savingsBalance = new Vector();

    Vector businessIDNo = new Vector();
    Vector businessNames = new Vector();
    Vector businessBalance = new Vector();



    public accountDetails(String accType, int pin, String nameGet, double balance)
    {
    if (accType.equalsIgnoreCase("CURRENT"))
    {
    currentIDNo.add(new Integer(pin));
    curentNames.add(new String(nameGet));
    currentBalance.add(new Double(balance));
    }

    else if (accType.equalsIgnoreCase("SAVINGS"))
    {
    savingsIDNo.add(new Integer(pin));
    savingsNames.add(new String(nameGet));
    savingsBalance.add(new Double(balance));
    }

    else if (accType.equalsIgnoreCase("BUSINESS"))
    {
    savingsIDNo.add(new Integer(pin));
    savingsNames.add(new String(nameGet));
    savingsBalance.add(new Double(balance));
    }

    // String report = nameGet +" has created a "+accType+" account with a balance of "+balance+".\n";
    }

    }

Similar Threads

  1. help java bank....
    By natsuki in forum Introductions
    Replies: 2
    Last Post: 07-25-2011, 03:36 AM
  2. Bank system giving me problems
    By ninozjava in forum New To Java
    Replies: 7
    Last Post: 06-19-2011, 09:06 PM
  3. Need help with bank system assignment - vectors
    By a3404987 in forum New To Java
    Replies: 1
    Last Post: 03-29-2011, 03:41 AM
  4. how to make to classes in the bank account program
    By buzzing in forum New To Java
    Replies: 3
    Last Post: 11-02-2010, 04:02 AM
  5. Java Question Bank
    By mgm2010 in forum New To Java
    Replies: 2
    Last Post: 07-31-2009, 06:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •