Example: Cumulative Principal Example

The amount of principal paid in the first year of a 30 year fixed rate mortgage is computed. The amount financed is $200,000 at an interest rate of 7.25% for 30 years.
import com.imsl.finance.*;
import java.text.NumberFormat;

public class cumprincEx1 {
    public static void main(String args[]) {
        double rate = 0.0725/12;
        int periods = 12*30;
        double pv = 200000;
        int start = 1;
        int end = 12;
        double total;
        
        total = Finance.cumprinc(rate, periods, pv, start, end,
        Finance.AT_END_OF_PERIOD);
        
        System.out.println("First year principal = " +
        NumberFormat.getCurrencyInstance().format(total));
    }
}

Output

First year principal = ($1,935.71)
Link to Java source.