Bank program

Hey guys i'm making a bank program for my calss and i wanna see what you guys think. My compiler says that I only have two errors but I do not think this is the case. It says i have
'{' expected line 29
'}' expected line 164
I'm confused on this so if you could give me some guidane as to how to fix this.....or how to fix anything else in my program please let me know....thanks
hwrd
Ps i almost forgot the code
import java.*;
import javax.swing.*;
import java.util.*;
public class BankAccount
          double total=0;
          double withdrawal=0;
          double deposit1=0;
          int choice=5;
          int accNumber=1;
          int password;
          int testwordint;
          int deletetrue;
          int withdrawpasstest;
          String delete;
          String deposit;
          String myPassword;
          String account;
          String testword;
          String withdrawpass;
          String withdrawalstring;
public class Account()
JOptionPane.showInputDialog("Enter 1 to create a new account/nEnter 2 to deposit/nEnter 3 to withdraw/nEnter 4 to delete your account");
if (choice == 1)
     createAccount()
else if (choice == 2)
     depositAccount()
else if (choie == 3)
     withdrawAccount()
else if (choice == 4)
     deleteAccount()
public void createAccount()
JOptionPane.showMessageDialog("Your account number has been assigned as one..Please keep this information for future refrence");
     myPassword = JOptionPane.showInputDialog("Please enter your two digit numeric password");
     password = Integer.parseInt(myPassword)
          JOptionPane.showMessageDialog("Your password is"+myPassword"...Please keep this information for future refrence");
      return Account();
public void depositAccount()
          account = JOptionPane.showInputDialog("Please Enter Your Account Number");
          if ( account != 1 )
               JOptionPane.showMessageDialog("I'm sorry but the account number you've entered does not exist.")
          else
          testword = JOptionPane.showInputDialog("Please Enter your two digit numeric password");
          testwordint = Integer.parseInt(testword);
          if(testwordint = password )
               deposit = JOptionPane.showMessageDialog("Please enter how much you would like to deposit.");
               deposit = Double.parseDouble(deposit);
               total = total + deposit;
               JOptionPane.showMessageDialog("Thank your for depositing into your account");
               return Account();
public void deleteAccount()
     delete = JOptionPane.showInputDialog("Press one if you really want to delete you accoount", JOptionPane.ERROR_MESSAGE);
     deletetrue = Integer.parseInt(delete);
     if (delete == 1)
          JOptionPane.showMessageDialog("Your account has been deleted");
          return Account;
     else if (delete != 1)
          return Account;
public void withdrawAccount()
     withdrawpasstest = JOptionPane.showInputdialog("Please enter your two digit numeric password.");
     withdrawpass = Integer.parseInt(withdrawpasstest);
     if (password == withdrawpass)
          withdrawalstring = JOptionPane.showInputDialog("How much would you like to withdraw from your account today?");
          withdrawal = Double.parseDouble(withdrawalstring);
          total = total-(withdrawal+ (10/100));
          if(total <= -100)
          JOptionPane.showMessageDialog("I'm sorry but you cannot withdraw any more. Because you have withdrawn too much already, your account has been terminated and you will be too....goodbye");
          System.exit(0);
          else if (total >= -100)
               JOptionPane.showMessageDialog("Thank you for withdrawing from you account. Have a nice day.");
               return Account();
          }

so now i get a
Exception in thread "main" java.lang.NoSuchMethodError: main
I treid running this in an applet but its not working...Also, I searched about this and many pepole said that if you run it in an applet it works, but not for me. My complier says this has no errors but when i execute i get the aforementioned error....
Any ideas?
hwrd
PS yet another ctrl c + crtl v
import java.*;
import javax.swing.*;
import java.util.*;
public class bankaccountest  {
          double total=0;
          double withdrawal=0;
          double deposit1 = 0;
          int choice=5;
          int accNumber=1;
          int password;
          int testwordint;
          int deletetrue;
          int withdrawpasstest;
          String delete;
          String depositstring;
          String myPassword;
          String account;
          String testword;
          String withdrawpass;
          String withdrawalstring;
          String choicestring;
          public void BankAccount()
               choicestring = JOptionPane.showInputDialog("Enter 1 to create a new account/nEnter 2 to deposit/nEnter 3 to withdraw/nEnter 4 to delete your account");
               choice = Integer.parseInt(choicestring);
               if (choice == 1)
                    createAccount();
               else if (choice == 2)
                    depositAccount();
               else if (choice == 3)
                    withdrawAccount();
               else if (choice == 4)
                    deleteAccount();
/* create account */
          public void createAccount()
               JOptionPane.showMessageDialog(null,"Your account number has been assigned as one..Please keep this information for future refrence");
               myPassword = JOptionPane.showInputDialog("Please enter your two digit numeric password");
               password = Integer.parseInt(myPassword);
               JOptionPane.showMessageDialog(null,"Your password is"+myPassword+"...Please keep this information for future refrence");
               //return Account();
          /* deposit to account void */     
          public void depositAccount()
               int account = Integer.parseInt(JOptionPane.showInputDialog("Please Enter Your Account Number"));
               if ( account != 1 )
                    JOptionPane.showMessageDialog(null,"I'm sorry but the account number you've entered does not exist.");
               }else{
                    testword = JOptionPane.showInputDialog(null, "Please Enter your two digit numeric password");
                    testwordint = Integer.parseInt(testword);
                    if(testwordint == password )     
                         depositstring = JOptionPane.showInputDialog( null, "Please enter how much you would like to deposit.");
                         deposit1 = Double.parseDouble(depositstring);
                         total = total + deposit1;
                         JOptionPane.showMessageDialog(null,"Thank your for depositing into your account");
                         //return Account();
     /* delete whole account void */     
          public void deleteAccount()
               delete = JOptionPane.showInputDialog(null, "Press one if you really want to delete you accoount");
               deletetrue = Integer.parseInt(delete);
               if (deletetrue == 1)
                    JOptionPane.showMessageDialog(null,"Your account has been deleted");
                    //return Account;
               else if (deletetrue != 1)
                    BankAccount();
     /*withdraw money from account void*/
          public void withdrawAccount()
               withdrawpass = JOptionPane.showInputDialog(null, "Please enter your two digit numeric password.");
               withdrawpasstest = Integer.parseInt(withdrawpass);
               if (password == withdrawpasstest){
                    withdrawalstring = JOptionPane.showInputDialog(null, "How much would you like to withdraw from your account today?");
                    withdrawal = Double.parseDouble(withdrawalstring);
                    total = total-(withdrawal+ (10/100));
                    if(total <= -100)
                         JOptionPane.showMessageDialog(null,"I'm sorry but you cannot withdraw any more. Because you have withdrawn too much already, your account has been terminated and you will be too....goodbye");
                         System.exit(0);
                    else if (total >= -100){
                         JOptionPane.showMessageDialog(null,"Thank you for withdrawing from you account. Have a nice day.");
                         //return Account();

Similar Messages

  • Help with bank program

    Hi all, i have created a basic bank program that uses a database to access data etc. One of my programs is called MainMenu which is my main class and another one called AccMaster. When I call for the AccMaster in MainMenu I keep getting an error in the line " { AccMaster acc = new AccMaster(); "
    Below is the code for the MainMenu:
    package bank;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import bank.*;
    public class MainMenu extends JFrame{
      /////// Declaration of Components ///////
      private JButton accMasterBtn, depositsBtn, withDrawalsBtn,dispBalBtn;
      private JLabel mainLbl;
      private JPanel panel1;
      public MainMenu() {
        super("Main Menu");
        // Get contentPane and set its layout
        Container container = getContentPane();
        container.setLayout(new FlowLayout());
        panel1 = new JPanel();
        mainLbl = new JLabel("            Main Menu");
        panel1.add(mainLbl);// add mainLbl to panel1
        accMasterBtn = new JButton("Accounts Master");
        panel1.add(accMasterBtn);// add accMasterBtn to panel1
        depositsBtn = new JButton("Deposits");
        panel1.add(depositsBtn);// add depositsBtn to panel1
        withDrawalsBtn = new JButton("Withdrawals");
        panel1.add(withDrawalsBtn);// add withDrawalsBtn to panel1
        dispBalBtn = new JButton("Display Balance");
        panel1.add(dispBalBtn); // add disoBalBtn to panel1
        panel1.setLayout(new GridLayout(5,1,10,10));
        container.add(panel1,BorderLayout.CENTER); // Add panel1 to container
        ////// AddActionListner to components ///////
        ButtonHandler handler = new ButtonHandler();
        accMasterBtn.addActionListener(handler);
        depositsBtn.addActionListener(handler);
        withDrawalsBtn.addActionListener(handler);
        dispBalBtn.addActionListener(handler);
        setSize(190,230);
        setVisible(true);
      private class ButtonHandler implements ActionListener{
        public void actionPerformed(ActionEvent event)
          if(event.getSource() == accMasterBtn)
          { AccMaster acc = new AccMaster(); /// Call AccMaster Frame
            acc.setResizable(false);
          else if(event.getSource() == depositsBtn)
          { depositDraw dep = new depositDraw(1); /// Call AccMaster Frame
            dep.setResizable(false);
          else if(event.getSource() == withDrawalsBtn)
          { depositDraw dep = new depositDraw(2); /// Call AccMaster Frame
            dep.setResizable(false);
          else if(event.getSource() == dispBalBtn)
          { DispBal bal = new DispBal(); /// Call AccMaster Frame
            bal.setResizable(false);
    }Here is the code for the AccMaster:
    package bank;
    import java.awt.*;
    import java.sql.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class AccMaster extends JFrame{
      /////// Declaration of Components ///////
      private JTextField accNoTxt, opnBalTxt;
      private JPanel panel1;
      private JLabel accNoLbl, opnBalLbl,accMasterLbl;
      private JFrame frame;
      public AccMaster() { // Set up GUI
      super ("Accounts Master"); // Set Frame Caption
      // Get content pane and set its layout
      Container container = getContentPane();
      container.setLayout(new FlowLayout());
      // Instantiate panel and set its layout
      panel1 = new JPanel();
      panel1.setLayout(new GridLayout(5,1,5,5));
      //// Add Components to panel1 ////
      accMasterLbl = new JLabel("Accounts Master");
      panel1.add(accMasterLbl);
      accNoLbl = new JLabel("Enter Account No.");
      panel1.add(accNoLbl);
      accNoTxt = new JTextField(15);
      panel1.add(accNoTxt);
      opnBalLbl = new JLabel("Enter Opening Balance.");
      panel1.add(opnBalLbl);
      opnBalTxt = new JTextField(15);
      panel1.add(opnBalTxt);
      //////// Add handlers to opnBalTxt ////////
      EventHandler handler = new EventHandler();
      opnBalTxt.addActionListener(handler);
      // Add panel1 to container
      container.add(panel1,BorderLayout.CENTER);
      setSize(250,200);
      setVisible(true);
      // Inner class for EventHandler
      private class EventHandler implements ActionListener{
       // Handles textbox  event
        public void actionPerformed(ActionEvent event)
          // If Enter is pressed when opnBalTxt box has focus
          if (event.getSource() == opnBalTxt &&
          opnBalTxt.getText() != null && opnBalTxt.getText() != " ")
        /// Confirm addition of information to database
        int choice = JOptionPane.showConfirmDialog(frame,
        "Add this information to the database?",
        "Banker",JOptionPane.YES_NO_OPTION);
        // If YES
        if(choice == JOptionPane.YES_OPTION)
          try {
          // load database driver class
          Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver");
          // connect to database
          Connection connection = DriverManager.getConnection("jdbc:odbc:Bank" );
          // create Statement to query database
          Statement statement = connection.createStatement();
          // Add new acount to Master table
          Statement stmt = connection.createStatement();
          stmt.executeUpdate(
          "INSERT INTO Master " +
          "VALUES ('" + accNoTxt.getText() + "', " + Long.parseLong(opnBalTxt.getText())+ ")");
          JOptionPane.showMessageDialog(null,"Data Entered into Database Successfully");
          opnBalTxt.setText(" ");
          accNoTxt.setText(" ");
          statement.close(); // Close statement
          connection.close(); // Close connection
          setVisible(false); // Hide frame
          }  // end try
          // detect problems interacting with the database
          catch ( SQLException sqlException ) {
             JOptionPane.showMessageDialog( null,
                sqlException.getMessage(), "Database Error",
                JOptionPane.ERROR_MESSAGE );
             System.exit( 1 );
          catch ( ClassNotFoundException classNotFound ) {
             JOptionPane.showMessageDialog( null,
                classNotFound.getMessage(), "Driver Not Found",
                JOptionPane.ERROR_MESSAGE );
             System.exit( 1 );
          // If NO
          else{
            opnBalTxt.setText(" ");
            accNoTxt.setText(" ");
            setVisible(false); // Hide Frame
      } // End EventHandler class
    } // End class AccMasterAll help will be MUCH appreciated

    sorry for the late reply. the error I am getting is:
    "MainMenu.java:59: cannot find symbol
    symbol : class AccMaster
    location: class bank.MainMenu.ButtonHandler
    { AccMaster acc = new AccMaster(); /// Call AccMaster Frame"

  • How do I create a new payment method in PeopleSoft 9.1 for Vendor payments via external bank program?

    We have contracted with a major banking institution to utilize their credit card program to transact vendor payments.  Basically, we generate a formatted file from our Pay Cycle.  The file is sent to the bank, who in turn notifies the participating vendors that their payments are available.  The vendors access their accounts and draw down our payment via their merchant credit card terminals/system.  We need to create a Payment Method 'CCD'; to be used by the PeopleSoft to update the vendor payables options, and indicate vouchers paid by this method.  PeopleSoft only delivers a few of the payment methods, but not one for credit card programs. Can anyone provide some direction on this and on how to create a new payment method?  Does PeopleSoft 9.2 have this payment method available? 

    Thanks for the suggestion...I did read up on the count function, but I don't think it will give me what I want. I need a a counter that increments for each payment made to a supplier, not a total of the number of payments made to that supplier.
    Any other suggestions, please?
    Tam.

  • Is there a personal banking program which allows you to print checks and download from bank?

    Hi,
    I am currently using iBank for personal banking. I am  unable to enter bills with 'terms' or due date or similar ledger type of entries.  Does anyone have any suggestions on other programs or if iBank has additional features I am not finding.  I tried quicken for mac several years ago, but the program did not allow printing of checks, and we print a lot of checks each month.
    Thanks for offering suggestions,
    AnneZ

    Why not get in touch with iBank's customer support website?
    (10.6.3)
    Use Software Update to update your os and anything else that needs to be updated.  Just may resolve your current iBank issues. 

  • Using numbers as a banking program

    Can I use numbers on the new iMac like a quicken type program? Download transactions, categorize and print reports?

    Numbers does not have the ability to download transactons and add new transactions to your spreadsheet. You can manually download your transactions from your bank (into an OFX file, I believe) then add them to your spreadsheet. You might be able to automate it further with scripting.
    Categories it can do. You can design reports.
    Numbers is a blank slate, unlike Quicken and other applications that are designed for the specific purpose you have in mind. If you want Numbers to do it, you have to design a Numbers document that does it. The amount of work required depends on what you want and need.

  • Simple Java Bank Program

    Can anyone please help?
    I am looking for a very simple client/server banking Java Application that performs basic function such as view account balance, and being able to deposit and withdraw money from the account.
    Any help would be much appreciated!

    You are asking for an application. I don't think anyone will ever start an open source banking system, because only banks will have an interest in them and they will develop their systems in-house.
    Sorry dude, but you'll have to switch on that brain of yours and do the work yourself.

  • Program/Bank Changes...

    Another odd one, I'm afraid.
    I have a number of external synths and modules that I control from Logic Pro 8 (all patched up). Most of these respond properly to inline program/bank changes (CC0/CC32/PRnum) - but one doesn't - the WaveStation. It does respond correctly in Cubase, so I don't think there's an issue with the Audio/Midi setup. What is even odder is that if I use the bank/program change lists, the program on the WS changes straight away, so Logic must be communicating the bank/program changes at some level to the WS - it just won't do it as part of a track, with a part just having the three MIDI events in it.
    Anyone got any ideas?

    Hi,
    Make sure you are transmitting on MIDI ch 2. This channel is usually used for changing programs, doing automation, etc...
    Cheers

  • Automatic clearing in electronic banking

    Hi all,
    I'm working with the electronic banking program to import statements and want to clear items from sub ledger accounts automatically.
    From the tests I have done so far, it seems that SAP always tries to locate the business partner via the bank details FIRST. In other words:
    IF business partner bank details are provided in the electronic bank statement
    THEN SAP takes this as leading in order to determine the business partner
    I do not want SAP to start the search via the bank account details. I have been using interpretation algorithm 020 (doc.number) and 031 (doc.number and customer from document) but still SAP always starts searching for the business partner based on the bank details.
    My test case is as follows:
    - I have a customer A without bank details maintained
    - I have a vendor B with bank details maintained
    - Customer A is in fact the SAME business parter as vendor B although they are not linked in their master data
    Now Customer A makes a payment to me and the bank provides the bank details of the customer AS WELL AS the invoice number. SAP then starts matching and finds vendor B because the customer bank details are maintained in the vendor master. Clearing from the vendor does -of course- not take place because the invoice exists on the customer, not the vendor. So a payment advice is created which holds the vendor account AND the invoice number.
    I cannot get SAP to avoid finding the vendor, and instead, find the customer with help of the document number that is also in the bank statement file.
    Hope the case is clear, any suggestions would be highly appreciated.
    Rene

    Hi Jay,
    Open items for G/L Accounts, Vendors and Customers can be cleared automatically by running the Clearing Program
    Set up predefined criteria for automatic clearing (Configuration)
    Program groups those items from an account that have the same
    u2022 Trading Partner ID
    u2022 Reconciliation Number
    u2022 Currency in which the General Ledger is updated
    u2022 Four freely definable criteria
    The program groups together items from an account that have the same reconciliation account number, currency, and Special G/L indicator, as well as pre-defined criteria from the document header or item such as the allocation field, reference number and amount.
    If the balance, in local currency, of the items within a group is zero, the system automatically clears them and creates clearing documents.
    Prerequisites for using the automatic clearing program:
    u2022 Accounts must be managed on an open item basis.
    u2022 Accounts to be cleared must be defined in customizing.
    The automatic payment program does not clear noted items, statistical posting, down payments, bills of exchange and items with withholding tax entries.
    When clearing open items in a foreign currency, differences may occur due to fluctuations in exchange rates. The system automatically posts these differences as realized gains or losses.
    Config: IMG>FA>GL. Accounting>Business  transactions>Open item clearing>Prepare automatic clearing.
    AS well see the notes for better understanding.
    Hope it gives better understanding.
    Respectfully,
    Vyas

  • Can't download file from bank. Error safari cant download qif

    I am trying to find a bank program that let's me run a budget and check register. I am trying to download a qif file to import my bank information but I get an errorbthat says safari can not download that type of file

    Just a theory but I think it holds some water, you can't download the file because you don't have an app that will let you save the file to on the iPad. I think that makes sense. I just downloaded a .qif from my bank site as a test and I was able to open the file in DropBox - not in any useful way - but I was able to save the downloaded file. My point is that if you choose one the apps the Dah-Veed has suggested to you, then you should be able to download the file if they work with the .qif format and I will trust Dah-Veed on that point.
    If there is no app that can handle the file on your iPad, you more than likely cannot download the file and that's why you get the message. You are "putting the cart before the horse" by trying to download the file.

  • Help with controlling Bank changes on Yamaha S90ES from Logic

    Can anyone please help me with getting Logic to control the bank changes on this beast. I have it controlling the patch changes no problem it is just the bank changes I need thanx

    Yeah, I'm a bit confused too. Assuming your keyboard is sending bank/program changes in the same format is receiving them, Logic will just record your data, and play it back as the keyboard sent it.
    Logic is ignoring bank changes sent from my Korg Triton.
    So, when recording into a region, you only get program changes, and not bank changes in your recorded data?
    However, Logic is sending bank changes to the Triton perfectly.
    From playing back a sequence recorded from program changes generated by the keyboard, or using Logic's bank/program change parameters in the instrument parameters?
    If I use my keyboard to set the instrument, Logic sets the program,
    but the bank is ignored.
    I don't understand what you mean by "Logic sets the program".
    n the event list, the incoming data looks as standard as could be:
    my keyboard is sending a bank MSB and LSB, via events 0 and 32,
    followed by a program change,
    And you are saying that if you play that back, the keyboard doesn't change sounds correctly?
    followed by a sysex "66/48" which I assume identifies the source
    of the message (the Korg).
    You can't assume anything - it could be anything. It could be a sysex patch dump of the patch, or it could be some mode setting. You'd need to read the keyboard manual to find out what it is.
    So the question is: how do I get Logic to PAY ATTENTION to the
    darn bank change being sent by my keyboard?
    I really don't understand what you mean by "PAY ATTENTION". If you squirt MIDI data at Logic, Logic will record it into a region, and then play it back, as would all sequencers. What should Logic do differently?

  • Code help in writing a Program which resolves the pricing issues

    Hello experts
    i was asked to write a report program with the following requirements,(This is to address the pricing issues KSE(company code A ) is facing with KST(another company code B) for S-Bank program(an important program we use it in SD)
    cananyone help with the code.? atlease a skeleton to start the program is highly appreciated.
    Thanks
    SP
    Selection Parameters
    Material
    Sold to party
    Sales Org
    Plant
    Sales order
    Actual goods movement dates
    Invoice number
    Sales order
    Report
    -Should detail only the Sbank scopes (all FERT’s beginning with S*)
    -Detail by line items
         -Material number
         -Serial number of device shipped
    -Serial number from SBANK_SERIAL_NUMBER characteristic in KSE_SN_ENDOSCOPES class contained in name plate data
         -Delivery number
         -Invoice number
         -Invoice price
         -Notification number
         -KST Repair level (coding field in notification)
         -KSE Repair level (activity code text from KSE-SM07 code group)
    Thanks
    SP

    http://java.sun.com/developer/onlineTraining/JavaMail/

  • Code help in writing a report Program

    Hello experts
    i was asked to write a report program with the following requirements,(This is to address the pricing issues KSE(company code A ) is facing with KST(another company code B) for S-Bank program(an important program we use it in SD)
    cananyone help with the code.? atlease a skeleton to start the program is highly appreciated.
    requirements..
    Selection Parameters
    Material
    Sold to party
    Sales Org
    Plant
    Sales order
    Actual goods movement dates
    Invoice number
    Sales order
    Report
    -Should detail only the Sbank scopes (all FERT’s beginning with S*)
    -Detail by line items
    -Material number
    -Serial number of device shipped
    -Serial number from SBANK_SERIAL_NUMBER characteristic in KSE_SN_ENDOSCOPES class contained in name plate data
    -Delivery number
    -Invoice number
    -Invoice price
    -Notification number
    -KST Repair level (coding field in notification)
    -KSE Repair level (activity code text from KSE-SM07 code group)
    Thanks
    SP

    Hello experts
    i was asked to write a report program with the following requirements,(This is to address the pricing issues KSE(company code A ) is facing with KST(another company code B) for S-Bank program(an important program we use it in SD)
    cananyone help with the code.? atlease a skeleton to start the program is highly appreciated.
    requirements..
    Selection Parameters
    Material
    Sold to party
    Sales Org
    Plant
    Sales order
    Actual goods movement dates
    Invoice number
    Sales order
    Report
    -Should detail only the Sbank scopes (all FERT’s beginning with S*)
    -Detail by line items
    -Material number
    -Serial number of device shipped
    -Serial number from SBANK_SERIAL_NUMBER characteristic in KSE_SN_ENDOSCOPES class contained in name plate data
    -Delivery number
    -Invoice number
    -Invoice price
    -Notification number
    -KST Repair level (coding field in notification)
    -KSE Repair level (activity code text from KSE-SM07 code group)
    Thanks
    SP

  • Since updating to IOS8. my mobile banking deposit locks up

    Since updating to IOS8....my mobile banking program locks up on my ipad3.  I use Safari and it is updated.  I have deleted the program and reinstalled.

    Please determine if the problems also occur in "Safe Mode":
    Safe Mode or "Safe Boot" is a troubleshooting mode that bypasses all third party system extensions and loads only required system components. Read about it: Starting up in Safe Mode
    You must disable FileVault before you can start your Mac in Safe Mode.
    Starting your Mac in Safe Mode will take longer than usual, graphics will not render smoothly, audio is disabled on some Macs, and some programs (iTunes for example) may not work at all.
    Merely starting your Mac in Safe Mode is not intended to resolve the problem, it's to observe its performance without certain additional components.
    To end Safe Mode restart your Mac normally. Shutdown will take longer as well.

  • Depositing money into bank and then updating balance.HELP

    Hi,
    Wondering if anyone could help me here. I'm codeing a bank program and one of the methods is depositing money into the account. now i can do that bit ok but i'm stuck when i want to update the display CORRECTLY afterwards.
    Have a look see.
    public class CurrentAccount
         private int accountNumber;
         private Student student1;
         private double interestRate;
         private int overdraft;
         private int initialAmount;
         private int withdrawAmount;
         private int depositAmount;
         private int balance;
         * Constructor for objects of class CurrentAccount
         public CurrentAccount(int accountNumber, Student newStudent, double interestRate, int overdraft, int initialAmount)
              this.accountNumber = accountNumber;
              student1 = newStudent;
              this.interestRate = interestRate;
              this.overdraft = overdraft;
              this.initialAmount = initialAmount;
    I'M HAVING TROUBLE BELOW. I WANT THE 'RETURN BALANCE' METHOD TO RETURN THE UPDATED BALANCE AFTER I HAVE DEPOSITED MONEY INTO THE ACCOUNT. I CURRENTLY JUST HAVE IT SET TO RETURNING THE INITIAL AMOUNT.
         * This method returns the current balance in the account.
         public int getBalance()
         return initialAmount;
         * This method allows you deposit money in your account.
         public void despositAmount(int amount)
         if(amount > 0)
         balance = initialAmount + amount;
         System.out.println("Your current balance is:" + balance);
         else
         System.out.println("You must deposit a positive amount of money. eg. &#8364;10");
    ANY HELP WOULD BE MUCH APPRECIATED! IF YOU NEED ANY MORE INFO OR IF I HAVEN'T MADE ANYTHING CLEAR THEN LET ME KNOW. CHEERS.

    I'm now having trouble with this method.
    If the amount attempting to be withdrawn is bigger than the balance then i want "You have insufficient funds" printed, this works ok. But then when i check the balance i get eg.-500 or whatever i attemped to withdraw. I just want the balance to be the same before i attempt to withdraw too big an amount. if you understand.
         * This method allows you to withdraw money from your account
         public void withdrawAmount(int amount)
         if(amount > 0)
         balance = balance - amount;
         System.out.println("You successfully withdrew: " + amount + " from your account");
         else
         System.out.println("You must withdraw a positive amount of money");
         if(amount > balance)
         balance = balance + amount - amount;
         System.out.println("You have insufficient funds");
         else
         balance = balance - amount;
         }

  • Using a class within a Vector

    ok,
    I writing a bank program where a user types in a string which is then broken into tokens. The tokens are separated using .nextToken( ) and the first token is used to determine what command the user wants to perform.
    My problem is that I am trying to place a class that Ive created within the vector and I cant seem to be able to get the tokens into the right place or retrieve them when they are needed.
    Here is what I have so far, ps I am very new to java.
    Project3Functions func = new Project3Functions();
    Vector vect = new Vector();
    do
    String firstLine = func.getLineInput();
    StringTokenizer tok = new StringTokenizer(firstLine," ");
    String hold = tok.nextToken();
    if(hold.equals("newAccount"))
    int index = Integer.parseInt(tok.nextToken());
    vect.setSize(index);
    vect.add(index, new Account());
    vect.add(index, Account.firstname = tok.nextToken());
    vect.add(index, Account.lastname = tok.nextToken());
    System.out.println("a new account was created");
    public class Account
    static String firstname = "";
    static String lastname = "";
    I am trying to create a new Account in the position <index> within the vector but I dont think Im referencing firstname and lastname correctly. Also how would I get firstname and lastname out of the vertoc to print them on the screen?
    Please someone help me.

    Your first problem is that you are defining firstname and lastname as static in your Account class. This means that no matter how many new accounts you create, there will only be one firstname and lastname, which are shared between them. their value will be whatever you set them to most recently.
    I think I know why you think you did that, however, and that leads to your second problem. You got complaints from the compiler because you tried to use Account.firstname to set firstname, etc. This only works for static variables. With your code, you are adding three new items to your vector for each new account you create, and you are adding them all to the same index. The last one wins! The other two die.
    Make your Account variables non-static and change the adding code:vect.add(index, newAcct = new Account());
    newAcct.firstname = tok.nextToken();
    newAcct.lastname = tok.nextToken();You should also take care that you only vect.setSize(index); when vect.size() < index; otherwise, if you have items up to 10, and then add an item at 6, items 7 through 10 will be irretrievably lost.
    Doug

Maybe you are looking for

  • How do I get my newer version of iPhoto back?

    I had iPhoto 7.1 (got there just from normal software upgrades - no purchases) and it began having trouble opening. It would begin to launch then just crash. I decided I needed to reinstall iPhoto. When I FINALLY found out how to do that, it put me b

  • Stop paying for service, reserve/keep phone number?

    Can I stop using and paying for one phone's service, yet reserve/keep the same phone number for when I want service again?

  • Running in Web Layout

    Hello, I created the Oracle 9i report as .RDF file, selecting to print both web and paper layout. The paper layout runs fine. However, when running a Web Layout from Reports Builder - I get a blank Internet Explorer page, and nothing else. Can you pl

  • Stuck on "Add Query"

    Hi Gurus, Just Installed Dashboard Builder and tried the query builder, however after login in on our network to select a universe it get stuck on "Add Query" panel where you cant do anything (nothing happens when clicking 'back' and 'next') you can

  • Version 6 screen

    I've just installed Version 6 of i-Tunes on my laptop and am really annoyed that approx the bottom third of the screen is now filled with iTunes Music Store clutter. Is there any way to reduce or eliminate this from my screen so that only the song li