Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialZachary Berry
5,997 PointsExpected 1,00 (Euro) bu the actual is *euro sign* 1,00 (Euro). I am confused
public static Function<Integer, String> getArgentinaPriceConverter() {
Locale argLocale = Locale.forLanguageTag("es-AR");
// This fluctuates and is hardcoded temporarily
BigDecimal argPesoToUsdRate = new BigDecimal("15.48");
Function<Integer, BigDecimal> usdToArgentinePesoConverter =
usd -> argPesoToUsdRate.multiply(new BigDecimal(usd));
Function<BigDecimal, String> argentineCurrencyFormatter = price -> {
Currency currentCurrency = Currency.getInstance(argLocale);
NumberFormat currencyFormatter =
NumberFormat.getCurrencyInstance(argLocale);
return String.format("%s (%s)",
currencyFormatter.format(price),
currentCurrency.getDisplayName()
);
};
return usdToArgentinePesoConverter.andThen(argentineCurrencyFormatter);
}
public static Function<Integer, String> createPriceConverter(Locale locale, BigDecimal usdRate) {
// TODO: Examine the hardcoded `getArgentinaPriceConverter` method
// TODO: Using the arguments passed into this method return a function that will work for any locale and rate
return usdPrice -> String.format("%s %s", NumberFormat.getCurrencyInstance(locale).
format(usdRate.multiply(BigDecimal.valueOf(usdPrice))), Currency.getInstance(locale).getDisplayName());
}
Zachary Berry
5,997 PointsZachary Berry
5,997 PointsI apologize for the poor formatting. The code that I wrote is at the bottom.