We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
// Write your code here.
String us = NumberFormat.getCurrencyInstance(Locale.US).format(payment);
String china = NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment);
String france = NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment);
BigDecimal bd = new BigDecimal(payment).setScale(2, RoundingMode.HALF_UP);
//BigDecimal a = new BigDecimal(payment);
DecimalFormat df = new DecimalFormat("#,###.00");
//df.setRoundingMode(RoundingMode.UP);
String india = "Rs."+String.valueOf(df.format(bd.doubleValue()));
System.out.println("US: " + us);
System.out.println("India: " + india);
System.out.println("China: " + china);
System.out.println("France: " + france);
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Currency Formatter
You are viewing a single comment's thread. Return to all comments →
// Write your code here. String us = NumberFormat.getCurrencyInstance(Locale.US).format(payment); String china = NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment); String france = NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment);