Results 1 to 2 of 2
  1. #1
    anthonym2121 is offline Member
    Join Date
    Apr 2009
    Rep Power

    Exclamation I don't want negative money [BUG]

    When the user tries to withdraw more money than whats in the account, it goes into negative and I don't want it to complete the transaction.

    result is the withdraw amount in the code below.

    Java Code:
    if(i != -1 && result > accountBalance[i]){
              result = 0.00;
              System.out.println("***Insufficient Funds***");

    Link to entire code:

  2. #2
    Singing Boyo is offline Senior Member
    Join Date
    Mar 2009
    Rep Power


    cant find the area in the code you want to look at. However, as a general suggestion, an if statement such as the code below may work.
    Java Code:
    if(withdraw > balance{
              System.out.println("***Insufficient Funds***");
    balance -= withdraw;
    System.out.println("Your new balance is " + balance;
    If the above doesn't make sense to you, ignore it, but remember it - might be useful!
    And if you just randomly taught yourself to program, well... you're just like me!

Similar Threads

  1. Work & Earn money from home, use rebate lower price save money $$$
    By arturmoniswork in forum Reviews / Advertising
    Replies: 0
    Last Post: 12-30-2008, 05:57 AM
  2. Negative elements
    By in forum New To Java
    Replies: 6
    Last Post: 12-15-2008, 04:48 AM
  3. [SOLVED] Array of first negative number
    By random0munky in forum New To Java
    Replies: 9
    Last Post: 12-08-2008, 11:17 PM
  4. Using double for money is a sin
    By fishtoprecords in forum New To Java
    Replies: 3
    Last Post: 11-28-2008, 07:05 AM
  5. Money to Words
    By javanewbie in forum New To Java
    Replies: 2
    Last Post: 06-30-2008, 04:27 AM

Posting Permissions

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