user5928703 - 13 days ago 5
Java Question

# I know I'm doing something wrong here with compound interest formula

Background: doing a budget portfolio program and I am trying to add in a compound interest calculator for a client's savings. Running into some problems here.
So here is the formula I currently have.

``````double comprinc= 25*(Math.pow((1+.05/12),(12*year)));
double futurev = saving1*(Math.pow((1+.05/12),((12*year)-1))/(.05/12));
``````

This is the following formula broken down into two halves

Total = [ P(1+r/n)^nt ] + [ PMT * (((1 + r/n)^nt - 1) / (r/n)) ]
or

Total = comprinc + futurev

P= principle =25

r= rate=.05

n= number of time interest is compounded

t= the number of years =5( have year currently set to 5)

PMT= initial savings=saving1=25

The problem is that I am testing this against an official compound interest calculator
and the answers I'm getting are no where close.

For example the answer that my program reads out is \$7700.28 after 5 years should be \$1739.32

``````double intPerPeriod = .05/12;