JAVA Looping a formula

I’m not 100% sure what you are trying to achive. But assuming you are trying to do some sort of compounding interest. This should help.

public static void main(String[] args)
{
    double startAmount = 1000;
    double ratePercentage = 0.05;
    double newAmount;

    newAmount = startAmount;

    for (int i = 0; i <= 10; i++){
        newAmount = newAmount + (newAmount * ratePercentage);
        System.out.println(i + " " + newAmount);

    }



}

Leave a Comment