Question:
Is there a java method for calculating monthly interest when the rate is given per annum?
CMY
2008-11-13 07:05:27 UTC
I know the rate is 3% 4% 5% per annum, but have to calculate the monthly interest rate for any given month
Five answers:
richarduie
2008-11-13 07:28:15 UTC
If you want a periodic equivalent interest rate that compounds to your annual rate...



// return the equivalent, compound interest rate for an annual interest

// rate of {annualRate} for time periods {noOfPeriods}, e.g.,

// noOfPeriods = 12 ==> monthly, noOfPeriods = 4 ==> quarterly, etc.

public double getPeriodicCompoundRate(double annualRate, double noOfPeriods) {

// division by zero is illegal - virtuous callers should

// check return to ensure error value was not returned

if (0 == noOfPeriod) return -999;

// calculate per period compound rate

return Math.pow(annualRate, 1/noOfPeriods);

}





If you want a periodic simple interest rate based on your annual rate...



// return the simple interest rate for an annual interest

// rate of {annualRate} for time periods {noOfPeriods}, e.g.,

// noOfPeriods = 12 ==> monthly, noOfPeriods = 4 ==> quarterly, etc.

public double getPeriodicSimpleRate(double annualRate, double noOfPeriods) {

// division by zero is illegal - virtuous callers should

// check return to ensure error value was not returned

if (0 == noOfPeriod) return -999;

// calculate per period compound rate

return annualRate/noOfPeriods;

}
asourapple100
2008-11-15 15:05:14 UTC
Well in this case, there is an algebraic expression that can help you out here. You'll simply need to convert it to Java code.



The equation is:



A = P(1 + r/n)^nt



A = total amount

P = principal amount

r = rate

n = number of times you compound it per year. For example, if compounded monthly, n would equal 12.

t = time in years.



Also, if you're going to be compounding continuously, there's a different formula:



Pe^rt



P = principal

e = the irrational number e. 2.7118281828...

r = rate

t = time in years
2008-11-13 08:09:59 UTC
My experience is little but I found this article I hope it helps

The attached Java file contains three methods: the div() method provides integer division with rounding towards negative infinity, which Java does not provide by itself (the normal division and modulus operations round towards zero). Use of this function makes the other methods usable with dates before 1970 because it will handle negative numbers correctly.

The wdnum() method returns the number of weekdays (excluding weekends) that have passed since Monday, 29 December 1969. It works by calculating the number of days since 1 January, 1970 (getTime() divided by the number of milliseconds in a day), adding 3 and returning the number of week days in full weeks and possibly a partial week that have passed since then.

The diff() method shows one possible use of wdnum(): it calculates the number of weekdays that have passed between two given dates, excluding weekends.

An example use of the diff() function would be to calculate the number of working days in a month. This could be done as follows:

Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("UTC"));

cal.set(year, month, 1);

Date d1 = cal.getTime();

cal.set(year, month + 1, 1);

Date d2 = cal.getTime();

System.out.println("Month " + month + ", " + year + " has " + diff(d1, d2) + " working days");

Note that the Calendar has to be set to the UTC time zone because the Date objects passed to diff() are expected to be relative to UTC. Here is where you may get JAVA http://hardcash59.etlux.hop.clickbank.net Here you may get free JAVA reports http://hardcash59.articleeq.hop.clickbank.net
sieg
2016-11-04 08:55:25 UTC
NPV is a greenback volume. So if the priority is approximately money, or value, then its NPV. IRR is relating to the interest value. Its sensible for comparing the value of return on one investment as against yet another. you could evaluate a $one thousand bond's return to a million greenback bridge. that's all relating to the interest value.
Chris C
2008-11-13 07:17:06 UTC
There is a simple formula.

Of course, it depends upon whether your performing "simple interest" calculations, or compound interest calculations.



ETA: Here's a much nicer looking link: http://en.wikipedia.org/wiki/Compound_interest



http://mathforum.org/dr.math/faq/faq.interest.html


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...