Example: Price of a Security that Pays at Maturity

The price per $100 face value of 1 year bond that pays interest at maturity is returned in this example.
import com.imsl.finance.*;
import java.text.*;
import java.util.*;

public class pricematEx1 {
    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("8/1/85");
        GregorianCalendar maturity = parse("7/1/86");
        GregorianCalendar issue = parse("7/1/85");
        double rate = .05;
        double yield = .05;
        DayCountBasis dcb = DayCountBasis.BasisNASD;
        double pricemat = Bond.pricemat(settlement, maturity, issue, 
        rate, yield, dcb);
        System.out.println("The price of the bond is " +pricemat);
    }
}

Output

The price of the bond is 99.98173970783533
Link to Java source.