Example: Amount Received at Maturity for a Fully Invested Security

The amount to be received at maturity for a 10 year bond is returned in this example.
import com.imsl.finance.*;
import java.text.*;
import java.util.*;

public class receivedEx1 {
    static final DateFormat dateFormat =
    DateFormat.getDateInstance(DateFormat.SHORT,  Locale.US);
    
    static private GregorianCalendar parse(String s) throws ParseException {
        GregorianCalendar cal = new GregorianCalendar();
        cal.setTime(dateFormat.parse(s));
        return cal;
    }
    
    public static void main(String args[]) throws ParseException {
        GregorianCalendar settlement = parse("7/1/85");
        GregorianCalendar maturity = parse("7/1/95");
        double investment = 7000.;
        double discount = .06;
        DayCountBasis dcb = DayCountBasis.BasisActual365;
        double received = Bond.received(settlement, maturity,
        investment, discount, dcb);
        System.out.println("The amount received at maturity for the bond is " +
        NumberFormat.getCurrencyInstance().format(received));
    }
}

Output

The amount received at maturity for the bond is $17,514.40
Link to Java source.