Java: Currency symbol based on ISO 4217 currency cod

Viewed 19098

Below program prints the Currency symbol given the ISO 4217 currency code.

import java.util.*;

public class Currency{

    public static void main(String args[]) {
        Currency myInstance = Currency.getInstance(args[0]);
        System.out.println(myInstance.getSymbol());
    }
}

Problem: Works fine when the string USD is input. For other inputs like EUR just return the Currency Code.

Sample input , ouput from the program:

input: java Currency USD 
output: $
input: java Currency EUR
output: EUR -> I expect the symbol of Euro here
4 Answers
Related