Results 1 to 2 of 2
  1. #1
    TitanVex is offline Member
    Join Date
    Nov 2011
    Rep Power

    Default 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.


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default 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

  1. Commands on java.
    By Slithice in forum New To Java
    Replies: 15
    Last Post: 11-15-2012, 10:06 AM
  2. using RMAN commands in Java
    By mario_tim in forum JDBC
    Replies: 4
    Last Post: 03-22-2011, 04:59 AM
  3. At commands in java
    By strictlydivine.elite in forum Advanced Java
    Replies: 1
    Last Post: 11-22-2010, 09:55 AM
  4. CMD is not reading commands
    By colonial in forum Forum Lobby
    Replies: 1
    Last Post: 03-15-2010, 02:36 AM
  5. InFile Commands not being recognized.
    By Tenn in forum New To Java
    Replies: 4
    Last Post: 02-13-2009, 03:50 PM

Posting Permissions

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