package com.imsl.test.example.finance; import com.imsl.finance.*; import java.text.NumberFormat; /** *
* Computes the internal rate of return on an investment.
* * A farmer buys 10 young cows and a bull for $4500. The first year he does not * expect to sell any calves, he just expects to feed them. Thereafter, he * expects to be able to sell calves to offset the cost of feed. He expects them * to be productive for 9 years, after which time he will liquidate the herd. * The internal rate of return is computed after 9 years. * * * @see Code * @see Output */ public class FinanceIrrEx1 { public static void main(String args[]) { double[] pmt = {-4500., -800., 800., 800., 600., 600., 800., 800., 700., 3000.}; double irr = Finance.irr(pmt); NumberFormat nf = NumberFormat.getPercentInstance(); nf.setMaximumFractionDigits(2); System.out.println("After 9 years, the internal rate of return on " + "the cows is " + nf.format(irr)); } }