Παράδειγμα: νομισματικές ισοτιμίες

import java.util.TreeMap;

public class FXConvert {

    private static TreeMap<String, Double> FXRate = new TreeMap<String, Double>();

    static double FXconvert(String from, String to, double value) {
        double euro = value / FXRate.get(from);
        return euro * FXRate.get(to);
    }

    public static void main(String args[]) {

        // Euro rates
        FXRate.put("USD", 1.27);
        FXRate.put("JPY", 126.0);
        FXRate.put("GBP", 0.68);
        FXRate.put("CHF", 1.57);
        FXRate.put("CAD", 1.53);
        FXRate.put("SEK", 9.03);

        System.out.println("5 SEK = " + FXconvert("SEK", "JPY", 5) + " JPY");
        System.out.println("100 GBP = " + FXconvert("GBP", "CHF", 100) + " CHF");
    }
}