package com.imsl.test.example.finance; import com.imsl.finance.*; import java.text.*; import java.util.*; /** *
* Computes the depreciation for the second accounting period.
* * In this example, the depreciation for the second accounting period is * calculated for an asset. * * @see Code * @see Output */ public class BondDepreciationEx1 { 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 { double cost = 2400.; GregorianCalendar issue = parse("11/1/92"); GregorianCalendar firstPeriod = parse("11/30/93"); double salvage = 300.; int period = 2; double rate = .15; DayCountBasis dcb = DayCountBasis.BasisNASD; double amordegrc = Bond.amordegrc(cost, issue, firstPeriod, salvage, period, rate, dcb); System.out.println("The depreciation for the second accounting " + "period is " + amordegrc); } }