Java Calendar Day getPrincipalAfterCompoundingInterest( Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval)

Here you can find the source of getPrincipalAfterCompoundingInterest( Calendar currentDate, Float principal, Integer depositPeriod, double interestPerDay, Integer compoundingInterval, Integer postingInterval)

Description

get Principal After Compounding Interest

License

Mozilla Public License

Declaration

public static Float getPrincipalAfterCompoundingInterest(
            Calendar currentDate, Float principal, Integer depositPeriod,
            double interestPerDay, Integer compoundingInterval,
            Integer postingInterval) 

Method Source Code

//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;
    }
}

Related

  1. getNextDay(Calendar cal)
  2. getNextDay(Calendar calendar, int day)
  3. getNextMonday(Calendar date)
  4. getNoonOfDay(Date day, Calendar cal)
  5. getOneDayLaterCalendar(Date date)
  6. getRelativeCalendar(int offsetDays)
  7. getSafeTimeForAllDay(Calendar cal)
  8. getStartAndEndOfDay(Calendar calendar)
  9. getStartOfDay(Calendar cal)