Results 1 to 5 of 5
- 05-22-2009, 07:30 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 62
- Rep Power
- 0
[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:
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.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** } }
All the best - FMJ.
- 05-22-2009, 07:35 PM #2
Member
- Join Date
- Mar 2009
- Posts
- 62
- Rep Power
- 0
PS - If you need further information please let me know.
Cheers - FMJ.
- 05-22-2009, 07:59 PM #3
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
- 05-22-2009, 08:00 PM #4
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
= is an assignment operator. == is for comparison.
- 05-23-2009, 12:43 AM #5
Member
- Join Date
- Mar 2009
- Posts
- 62
- Rep Power
- 0
Similar Threads
-
[SOLVED] Noobie - Calculating Percentages
By fullmetaljacket in forum New To JavaReplies: 16Last Post: 05-22-2009, 01:10 AM -
[SOLVED] Noobie Help! Constructors
By fullmetaljacket in forum New To JavaReplies: 6Last Post: 05-14-2009, 02:52 AM -
Problems in JSP : Need help
By raj4u in forum JavaServer Pages (JSP) and JSTLReplies: 1Last Post: 02-07-2008, 10:06 AM -
a few problems
By gary in forum AWT / SwingReplies: 0Last Post: 07-11-2007, 04:57 PM -
problems with JPA
By Ed in forum New To JavaReplies: 2Last Post: 07-04-2007, 05:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks