Results 1 to 5 of 5
  1. #1
    hacikho is offline Member
    Join Date
    Sep 2009
    Posts
    35
    Rep Power
    0

    Default Calculate Interest

    On my BankAccount program one of the method should calculate interest as below.

    Calculate interest: The interest is compounded daily and is calculated as follows

    IN = P(1 + i)n P (n is power, I could not make it as power visually in here)
    Where

    IN is interest

    P is Principle

    i is the daily percentage rate calculated as yearly interest / 365

    n is the number of days(I make it 30 on my program to calculate monthly interest)

    User will enter the balance and annual interest rate. Here is my method and result. I could not apply this formula to my method correctly because my result in not correct. If you guys give me a hand that I will appreciate you.
    Java Code:
    //Interest Calculation
        public void interest()
        {
        	interest = balance * Math.pow((1 + annualInterestRate/365), 30)- balance;
        }
    Java Code:
    Enter Your Name: 
    john
    Enter Your Account Number: 
    35
    Enter Your Begining Balance
    200
    Enter Your Deposit
    100
    Enter Your Withraw
    200
    Enter the Annual Interest Rate
    10
    Account Holder Name: john
    Account Number 35
    [COLOR="Red"]Account Balance: 100.0
    Daily Interest Rate 0.0273972602739726
    Monthly Interest 124.98424052172155
    Account Balance after Interest Added 224.98424052172155[/COLOR]
    
    Process completed.

  2. #2
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    What is the value & variable type of annualInterestRate? (Note that it should be a double, otherwise its division by 365 may result in undesired rounding.)

  3. #3
    hacikho is offline Member
    Join Date
    Sep 2009
    Posts
    35
    Rep Power
    0

    Default

    value is 10 and data type is double

  4. #4
    Zack's Avatar
    Zack is offline Senior Member
    Join Date
    Jun 2010
    Location
    Destiny Islands
    Posts
    692
    Rep Power
    5

    Default

    If you want it to be a 10% annual interest rate, then its value should be 0.1, not 10.0. When using 10, I get the same number as your program. When using 0.1, I get $0.825191... which seems right.

  5. #5
    hacikho is offline Member
    Join Date
    Sep 2009
    Posts
    35
    Rep Power
    0

    Default

    Thanks I was assuming when I put 10 it was 10% however i was wrong, so when I enter 0.1 I have correct value

Similar Threads

  1. Calculating compound interest using ONLY integers.
    By AprilFlowers in forum New To Java
    Replies: 2
    Last Post: 10-21-2009, 06:47 AM
  2. Help with compound interest program pleaze
    By Smirre in forum New To Java
    Replies: 1
    Last Post: 01-19-2009, 09:31 PM
  3. HELP FAST!!----Interest Calculator
    By Coop33 in forum New To Java
    Replies: 8
    Last Post: 10-15-2008, 01:44 PM
  4. calculating Bank interest rate.
    By dotnet007 in forum New To Java
    Replies: 10
    Last Post: 05-13-2008, 09:30 AM
  5. Calculate what e1 and e2 should be
    By Legoland in forum New To Java
    Replies: 11
    Last Post: 07-02-2007, 06:01 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
  •