Example: Effective Rate

In this example the effective interest rate is computed given that the nominal rate is 6.0% and that the interest will be compounded quarterly.
import com.imsl.finance.*;
import java.text.NumberFormat;

public class effectEx1 {
    public static void main(String args[]) {
        double nominalRate = .06;
        int nper = 4;
        double effectiveRate;
        
        effectiveRate = Finance.effect(nominalRate, nper);
        NumberFormat nf = NumberFormat.getPercentInstance();
        nf.setMaximumFractionDigits(2);
        System.out.println("The effective rate of the nominal rate, 6.0%, " +
        "compounded quarterly is " +nf.format(effectiveRate));
    }
}

Output

The effective rate of the nominal rate, 6.0%, compounded quarterly is 6.14%
Link to Java source.