### Example: Interest Rate

Someone obtains a $20,000 loan to buy a car. They make $350 a month payments for 70 months. Here, the interest rate of the loan is computed.
import com.imsl.finance.*;
import java.text.NumberFormat;
public class rateEx1 {
public static void main(String args[]) {
double rate;
int nper = 70;
double pmt = -350.;
double pv = 20000;
double fv = 0.;
int when = Finance.AT_BEGINNING_OF_PERIOD;
rate = Finance.rate(nper, pmt, pv, fv, when) * 12;
NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMaximumFractionDigits(2);
System.out.println("The computed interest rate on the loan is "
+ nf.format(rate));
}
}

#### Output

The computed interest rate on the loan is 7.35%

Link to Java source.