/**
*
*/
package com.hsbc.team.fantasy8.util;
import java.util.HashMap;
import java.util.Map;
/**
* @author 34028450
*
*/
public class Currency {
private static Map exchangeRateToUSD = new HashMap();
/**
*
*/
private Currency() {
}
public static double convertToUSD(String currency, double amount) {
if (exchangeRateToUSD.isEmpty()) {
exchangeRateToUSD.put("GBP", new Double("1.6213"));
exchangeRateToUSD.put("EUR", new Double("1.3128"));
}
double usdAmount = amount;
if (exchangeRateToUSD.containsKey(currency)) {
usdAmount = amount * ((Double) exchangeRateToUSD.get(currency)).doubleValue();
} else {
System.out.println("*Error: Currency cannot be found");
}
return usdAmount;
}
/**
* @param args
*/
public static void main(String[] args) {
System.out.println(convertToUSD("GBP", 10));
System.out.println(convertToUSD("EUR", 10));
System.out.println(convertToUSD("CNY", 10));
}
}