Example: Depreciation - Straight Line Method

The straight line depreciation for one period of an asset with a life of 24 months, an initial cost of $2500 and a salvage value of $500 is computed.
import com.imsl.finance.*;
import java.text.NumberFormat;

public class slnEx1 {
    public static void main(String args[]) {
        double cost = 2500;
        double salvage = 500;
        int life = 24;
        
        double sln = Finance.sln(cost, salvage, life);
        System.out.println("The straight line depreciation of the asset " + 
        "for one period is " + NumberFormat.getCurrencyInstance().format(sln));
    }
}

Output

The straight line depreciation of the asset for one period is $83.33
Link to Java source.