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. €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;
     }

Similar Messages

  • BF tried to update to ios6 on iphone 4 but crashed half way through saying it needed to plugged into iTunes and then restored so after it was 'restoring' he had an error message come up say to couldn't be restored....what should be do next?

    BF tried to update to ios6 on iphone 4 but crashed half way through saying it needed to plugged into iTunes and then restored so after it was 'restoring' he had an error message come up say to couldn't be restored....what should be do next as the phone is in a complete non working condition

    Spent hours trying everything suggested and finally this morning hit on a solution. iTunes must be run as an administrator. Even though you are logged into your PC as an administrator, using the iTunes shortcut does not make you an administrator in iTunes. I found this out by using the diagnostics in iTunes and reading through the results report.
    I am using Windows 7, so I clicked the start button and right clicked on iTunes and selected "Run as an adimistrator". The first restore attempt got the 4013 error. I then did the DFU thing, hold power and home buttons for 10 seconds, release power and continue holding home for 10 more seconds.
    iTunes gave me the restore message and I clicked it. I clicked the restore iPhone button and it started. The drivers loaded a couple of times. I got the apple logo with the progress bar and this time instead of disappearing, it started to fill in.
    End result, a successful restore to factory settings and a happy 14 year old.
    Hope this helps others.

  • HT4972 Trying to update my iPad2 but when I go into settings and then general. I don't have a option for software update.. But iPad is so behind can you you?

    How do I update my iPad? When I go into setting and then general I do not have a option saying software upadate..

    Don't stop reading ...go all the way through the article. The instructions are in there.
    Update your device using iTunes
    http://support.apple.com/kb/HT4623

  • Before i updated to ios6 i took off all my apps into iTunes and then when i went to put them back in on my ipod it says " 'app name' failed to install" anyone know whats wrong?

    before i updated to ios6 i took off all my apps and put them into iTunes and then when i went to put them back in it says syncing like normal then when i look on my ipod it says " 'app name' failed to install" anyone know whats wrong?

    In iTUnes 7....
    Connect the ipod. On the ipod summery page hit the "Music" tab. Set it to "Auto update select" and check the playlist you want on the ipod then hit "Apply" in the bottom righthand corner

  • How I can edit and then update multiple rows via JSP to Action Class?

    Hi All,
    I have a JSP page which allows users to edit the some properties for all Object returned by the db. They can then submit the changes to a Action Class which i.e.
    <form action="/SaveUserNames">
    <table>
    <c:forEach items='${requestScope["users"]}' var='user'>
    <tr align="center">
    <td><input type="text" name="userBean[ i ].firstname" value="..."/></td>
    <td><input type="text" name="userBean[ i ].surname" value="..."/></td>
    </tr>
    </c:forEach>
    <tr>
    <td><button type="submit">Save</button></td>
    </tr>
    </table>
    </form>
    In the ActionForm, there is a method, which would allow the Struts code to update my beans with the data the user editted:
    public UserBean getUserBean(int i) {
    return userBeanList.item(i);
    Although I am not sure how I can update the beans in the Action Class with what the user submitted.
    Can somebody help me for this point or can me suggest any design pattern to solve this points?
    Thanks
    Amit

    Fetch values for each user data and put into a Hashtable and then update.
    Userid is the key
    User related data is the bean (like firstname, lastname, age, job, etc), so you have ArrayList of user bean.

  • How do I select and email a whole lot of photos on my iPad from my iPad emails? It seems I have to go into Email and then insert one photo at a time? Isn't there a way to select all in the photos and then email the batch.?

    How do I select and email a whole lot of photos on my iPad from my iPad emails? It seems I have to go into Email and then insert one photo at a time? Isn't there a way to select all in the photos and then email the batch.?

    Actually, you can email up to 5 at a time from the Photos app. Select any more and the email share option will not appear.
    If you explain why you need to email large numbers of photos, we might be able to offer an alternative.

  • Hi, the problem of deleting files / videos seeds desktop to go into Terminal and then sudo rm-rf ~ /. Trash Pohangina the answers I've had e of someone in her forum but when I write procedures line in Terminal as the Krever my password and it can not writ

    Hi, the problem of deleting files / videos seeds desktop to go into Terminal and then sudo rm-rf ~ /. Trash Pohangina the answers I've had e of someone in her forum but when I write procedures line in Terminal as the Krever my password and it can not write anything there, I write but nothing comes and my problem is not löst.När I want to delete the movie / video image Frin desktop still arrive Finder wants to make changes.Type your password to allow this. But even that I type my password file / video is left I need help in an easier way or another set-even those on the terminal that I can not type my password to solve the problem Regards Toni

    If you want to preserve the data on the boot drive, you must try to back up now, before you do anything else.
    There are several ways to back up a Mac that isn't fully working. You need an external hard drive to hold the backup data.
    1. Boot from the Recovery partition or from a local Time Machine backup volume (option key at startup.) Launch Disk Utility and follow the instructions in this support article, under “Instructions for backing up to an external hard disk via Disk Utility.”
    2. If you have access to a working Mac, and both it and the non-working Mac have FireWire or Thunderbolt ports, boot the non-working Mac in target disk mode. Use the working Mac to copy the data to another drive. This technique won't work with USB, Ethernet, Wi-Fi, or Bluetooth.
    3. If the internal drive of the non-working Mac is user-replaceable, remove it and mount it in an external enclosure or drive dock. Use another Mac to copy the data.

  • Upload a doc into SAP and then FAX it

    Hi
    I'm looking for a method of uploading a doc into SAP and then FAX it to a customer.
    What currently happens is this:
    1.  SAP creates a document, which is saved to a UNIX directory as a text file.
    2.  An external process takes this file, uses the info and creates a new file with alot  more info than SAP has.  This new file is saved to another UNIX directory.
    3.  This is where I'm stuck.  I would like SAP to upload this new text file (or files) and fax each one.
    The filename will contain a document number that SAP can then use to check customer master and obtain correct FAX number.
    Can anyone provide a few pointers?
    thanks,
    Stephen

    Hi Stephen,
    Your SAPConnect config basically sends a SAPOffice message to your fax server, so to send your unix file in the same way you need an ABAP to create a SAPoffice message.
    The steps in your program will be something like;
    Read the unix file (OPEN DATASET, TRANSFER etc)
    Format the data if necessary
    Use a function module like SO_DOCUMENT_SEND_API1 to create the message
    Provided you maintain the correct recipient parameters SAPconnect should process this to the fax server.
    An alternative is to create a spool then pass this to SAPoffice, the approach is similar but the FMs needed will be different.
    Regards,
    Nick

  • Whenever I try to upload photos into iPhoto, they load but when importing it just stops a picyure or two into it and then just sits there. I can't stop the import so I have to shut off my camera when it is importing and start again. Help?

    Whenever I try to upload photos into iPhoto, they load but when importing it just stops a picture or two into it and then just sits there. I can't stop the import so I have to shut off my camera when it is importing and start again. Does anyone know how to fix this?

    As a test  launch iPhoto with the Option key held down and create a new, test library.  Tru importing from your camera to it and to see if the same problem persists. Does it?
    OT

  • Subtitle workflow. Is it possible to import srt files into premiere and then export to Encore?

    Hi, I'm editing a series of short documentaries that wil be published in DVD with subtitles, and I'm wondering if there's any way to import srt files into Premiere and then export the project to Encore.

    You can easily (and better, IMHO) do what you want in Adobe Prelude.  It's part of the CC subscription, and may have been included with CS6.
    Open the Ingest panel, navigate to the external drive where you have your source clips, make the thumbnails in the Ingest panel comfortably large, click a video clip to enable scrubbing, and use the J-K-L keys to navigate playback through the clips.  Put a check mark on the clips you want and be sure to select and set up the Transfer option on the right side of the panel before ingesting.  Don't select the Transcode option.
    Cheers,
    Jeff

  • HT1414 When i go into settings and then Wi-fi, it is not letting me flip the 'off' to 'on'. What do i do to relase the flip switch so i can on Wi-fi?

    When i go into settings and then Wi-fi, it is not letting me flip the 'off' to 'on'. What do i do to relase the flip switch so i can on Wi-fi?

    Hey there Devc_04!
    I have an article here for you that can address your issue:
    iOS: Wi-Fi settings grayed out or dim
    http://support.apple.com/kb/ts1559
    Thanks for coming to the Apple Support Communities!
    Regards,
    Braden

  • I need to run the program in back ground and then update two fields

    hi gurus
    i need to run the program in back ground and then update two fields in the z table by mm02 transaction by using bapis , can any one give me the code for this.
    Message was edited by:
            Rocky

    hi
    good
    go through this link
    http://www.sapdb.org/7.4/htmhelp/34/ee7fba293911d3a97d00a0c9449261/content.htm
    thanks
    mrutyun^

  • Is it possible to copy a DVD into iTunes and then upload it to my iPad? Is there any way of doing this?

    Is it possible to copy a DVD into iTunes and then upload it to my iPad? Is there any way of doing this?

    Sure, just use Handbrake to encode the DVD movie into a format that is playable on iTunes and on your iPad:
    http://handbrake.fr/downloads.php
    Once the encoding is complete, move the movie file from your desktop into iTunes and then sync your iPad.  Presto, the movie is on your iPad!

  • How do I organize my photos into events and then move from my mac to my Ipad

    New to mac.  Have moved 3000 pictures to Iphoto.  How do I organize into events and then download those events to my ipad?

    Have a look at the tutorials here
    http://www.apple.com/findouthow/photos/
    Essentailly, your photos are broken into Events automtically. You sync with your iPad via iTunes.
    Regards
    TD

  • I am trying to re install my lightroom student addition.  I have the serial number and was told to do the trial again and then update to purchase. i am unable to figure out how to do this

    i am trying to re install my lightroom student addition.  I have the serial number and was told to do the trial again and then update to purchase. i am unable to figure out how to do this

    Emily5lexi which version of Lightroom are you wishing to install?  Also what operating system are you using?

Maybe you are looking for

  • How do I access *load paragraph styles* from the styles pallet menu?

    Adobe help informs me that I can bring styles from other documents into an existing document by doing this: "To copy paragraph styles from one publication to another choose Load Paragraph Styles from the Paragraph Styles panel menu." I do not see any

  • Error message from new_block_instance freezes form

    I show a message in the new block_instance of a form by using fnd_message.error. The messages shows up fine but the form freezes after that. Following is the code : if name_in('promise_demand.atp_error_message') is not null then fnd_message.set_strin

  • Thumbnails will not load in elements 12 organizer, using windows 8.1

    The thumbnails will not load (hourglass icon appears on each photo) on Elements 12 using Windows 8.1.  I have updated the Elements to Core Version 12.1.  Any ideas how to fix this?

  • Run time error while running Session Bean sample

    Hi, I am new to EJB. When I try to run one sample session bean, I am getting following exeception. javax.naming.NoInitialContextException: Need to specify class name in environment or system property, or as an applet parameter, or in an application r

  • Standar query

    I have standard query. I save as the query and make some changes to the saved as query. But the changes that i am making to the save as query are getting applied to the Standard query. I also tried copying the query and making the changes to the copi