Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2009
    Posts
    62
    Rep Power
    0

    Default [SOLVED] Problems using if / else? Noobie! :-)

    Hey Guys,

    I'm slowly starting to get into this Java thing! But I have some problems using if / else.

    I have an account. I need to write a method called transfer() which transfers an amount from an overpaymentBalance into currentBalance as long as annualPayments are = 0.0 and annualPayments are <= totalAllowedPerYear. When the overpaymentBalance is transfered, it should update the amount debited and update annualPayments with the credit.

    If annualPayments are > 0.0 then no action should be taken.

    The problem is that I have experience using if when an action is taken but I am unsure what to do if no action is taken?

    The code I have so far is:

    Java Code:
    public void transfer()
    {
           double credited;
           double debited; 
           credited = this.getOverpaymentBalance();
           debited = this.getOverpaymentBalance() - credited;
           {
              if ((this.getAnnualDeposits() = 0.0) && this.gettotalAllowedPerYear() <= getMaxDepositPerYear())
              {
                 this.credit(credited);
                 this.setOverpaymentBalance(debited);
                 this.setAnnualDeposits(credited);
              }  
              if (this.getDepositsThisYear() > 0.0)
              }
               **unsure on action to take here**
              }
          }
    I am getting errors all over the place, including illegal start of the expression and expecting )... If you have any ideas I would be very grateful.

    All the best - FMJ.

  2. #2
    Join Date
    Mar 2009
    Posts
    62
    Rep Power
    0

    Default

    PS - If you need further information please let me know.

    Cheers - FMJ.

  3. #3
    OrangeDog's Avatar
    OrangeDog is offline Senior Member
    Join Date
    Jan 2009
    Location
    Cambridge, UK
    Posts
    838
    Rep Power
    6

    Default

    I believe you'll find that // indicates a comment, not **.
    If no action is to be taken, then do nothing. There is no "do nothing" command, you just don't put anything.

    Have you taken the time to go through all of the relevant Java Tutorials? You may find it quicker than asking every syntax question here.
    Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
    How To Ask Questions The Smart Way

  4. #4
    emceenugget is offline Senior Member
    Join Date
    Sep 2008
    Posts
    564
    Rep Power
    7

    Default

    = is an assignment operator. == is for comparison.

  5. #5
    Join Date
    Mar 2009
    Posts
    62
    Rep Power
    0

Similar Threads

  1. [SOLVED] Noobie - Calculating Percentages
    By fullmetaljacket in forum New To Java
    Replies: 16
    Last Post: 05-22-2009, 02:10 AM
  2. [SOLVED] Noobie Help! Constructors
    By fullmetaljacket in forum New To Java
    Replies: 6
    Last Post: 05-14-2009, 03:52 AM
  3. Problems in JSP : Need help
    By raj4u in forum JavaServer Pages (JSP) and JSTL
    Replies: 1
    Last Post: 02-07-2008, 11:06 AM
  4. a few problems
    By gary in forum AWT / Swing
    Replies: 0
    Last Post: 07-11-2007, 05:57 PM
  5. problems with JPA
    By Ed in forum New To Java
    Replies: 2
    Last Post: 07-04-2007, 06:34 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
  •