Results 1 to 3 of 3
  1. #1
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default Changing balance variable so its never negative

    Got answer.
    Last edited by coding; 03-08-2011 at 04:38 AM.

  2. #2
    NRitH is offline Senior Member
    Join Date
    Feb 2011
    Posts
    118
    Rep Power
    0

    Default

    Quote Originally Posted by coding View Post


    I need some assistants.
    So I have to modify the Account class so that the balance variable can never become negative. You'll need to change the primary constructor and the deposit and withdraw methods. If the balance threatens to become negative, set it to zero instead. And the hint was. Use the math.max method to determine which is larer, the intended balance or zero.

    How can I do this? Right now I'm at a blank.
    This is very straightforward. Each pf those methods can change the balance, right? In each case, add or subtract the method argument to or from the current balance. If Math.max(balance, intendedBalance) == balance, then set balance to 0; otherwise, set it to the intended balance.

  3. #3
    coding is offline Member
    Join Date
    Jan 2011
    Posts
    40
    Rep Power
    0

    Default

    Could you clarify taht a lot better? I'm still kind of confused.

Similar Threads

  1. Replies: 0
    Last Post: 08-14-2010, 10:09 AM
  2. Calculate the remaining balance on a loan
    By ŖΫ ỏ Ңόρę in forum New To Java
    Replies: 9
    Last Post: 03-30-2010, 03:38 AM
  3. Color Balance
    By THEAniKan in forum Java 2D
    Replies: 2
    Last Post: 09-14-2009, 04:34 PM
  4. Binary Tree Deletion & Balance Methods
    By sev51 in forum New To Java
    Replies: 1
    Last Post: 01-27-2009, 04:26 PM
  5. Negative elements
    By swikar.java in forum New To Java
    Replies: 6
    Last Post: 12-15-2008, 04:48 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
  •