I have to make an application that calculates the compound interest per month. The principal is $1000, and the rate is 2.65%. I have attempted to code the application and succeeded in some areas. However, I am having problems with the actual math and have tried different ways to get the compound interest with no success. The link is pasted below. Any help would be appreciated, thank you.
import java.util.Scanner;
class calculator{
private double mni, mni2, mni3;
private double intot = 1000;
private int a, c;
double cinterest (int x){
for(a=0;a<x+1;a++){
mni = intot * .0265;
intot = mni + intot;
//mni3 = (intot - mni) - 1000;
mni3 = (intot - mni);
}
return(mni3);
}
}
class intcalc{
public static void main(String[] args){
calculator interest = new calculator();
Scanner uinput = new Scanner(System.in);
int months[] = {2, 5, 10, 500};
int b;
for(b=0;b<4;b++){
System.out.println("Interest at " +
months[b] + " months is: " + interest.cinterest(months[b]));
}
}
}