Results 1 to 2 of 2
- 11-05-2011, 04:22 PM #1
Member
- Join Date
- Nov 2011
- Posts
- 1
- Rep Power
- 0
Help with returning 'set' commands
I am fairly new to java. I have to make a program about a Savings Account. In one class, I have defined the following:
private double interest;
....
public double getInterest() {
return interest;
}
public void setInterest(double interest) {
interest = (newBalance * (interestRate/12)) + newBalance;
}
I then make a demo class to test it. However, I am not sure what I have to do to make the variable work. I have defined the variable interestTotal, but I can't get the 'one.setInterest()' to work, no matter what I put in it. All I want is for the 'one.setInterest()' to call upon its command (from up above) if that is possible.
interestTotal = interestTotal + one.setInterest();
Like I said, I am fairly new to java so I am pretty baffled right now. Any help is appreciated. Ideally, I would rather have the command to be something like:
one.setInterest = one.setInterest() + one.getInterest();
But that doesn't work either....
Thanks a lot.
-TitanVex
-
Re: Help with returning 'set' commands
I'm not sure that you should have an interest field or a setInterest(...) method. Instead consider having just a getInterest method, one that calculates the value based on the current newBalance and InterestRate value.
Similar Threads
-
Commands on java.
By Slithice in forum New To JavaReplies: 15Last Post: 11-15-2012, 10:06 AM -
using RMAN commands in Java
By mario_tim in forum JDBCReplies: 4Last Post: 03-22-2011, 04:59 AM -
At commands in java
By strictlydivine.elite in forum Advanced JavaReplies: 1Last Post: 11-22-2010, 09:55 AM -
CMD is not reading commands
By colonial in forum Forum LobbyReplies: 1Last Post: 03-15-2010, 02:36 AM -
InFile Commands not being recognized.
By Tenn in forum New To JavaReplies: 4Last Post: 02-13-2009, 03:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks