Example: Price Conversion - Fractional Dollars

A fractional dollar price, in this case 1 3/8, is converted to a decimal price.
import com.imsl.finance.*;
import java.text.NumberFormat;

public class dollardeEx1 {
    public static void main(String args[]) {
        double fractionalDollar = 1.3;
        int fraction = 8;
        
        double dollardec = Finance.dollarde(fractionalDollar, fraction);
        System.out.println("The fractional dollar 1.3 = " +
        NumberFormat.getCurrencyInstance().format(dollardec));
    }
}

Output

The fractional dollar 1.3 = $1.38
Link to Java source.