Here you can find the source of getPrincipalAfterCompoundingInterest( Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval)
public static Float getPrincipalAfterCompoundingInterest( Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval)
//package com.java2s; //License from project: Mozilla Public License import java.util.Calendar; public class Main { public static Float getPrincipalAfterCompoundingInterest( Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval) { Float totalInterest = 0.0f; Float interestEarned = 0.0f; for (int i = 1; i <= depositPeriod; i++) { Integer daysInMonth = currentDate .getActualMaximum(Calendar.DATE); for (int j = 0; j < daysInMonth; j++) { interestEarned = (float) (principal * interestPerDay); totalInterest += interestEarned; if (compoundingInterval == 0) { principal += interestEarned; }// w w w . j a va 2 s . c o m } if ((i % postingInterval) == 0 || i == depositPeriod) { if (compoundingInterval != 0) { principal += totalInterest; } totalInterest = 0.0f; System.out.println(principal); } currentDate.add(Calendar.MONTH, 1); interestEarned = 0.0f; } return principal; } }