You are viewing a single comment's thread. Return to all comments →
public class Solution {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double payment = scanner.nextDouble(); scanner.close(); Locale indiaLocale = new Locale ("en", "IN"); NumberFormat numUS = NumberFormat.getCurrencyInstance(Locale.US); String us = numUS.format(payment); NumberFormat numIND = NumberFormat.getCurrencyInstance(indiaLocale); String india = numIND.format(payment).replace("\u20B9", "Rs."); NumberFormat numCHI = NumberFormat.getCurrencyInstance(Locale.CHINA); String china = numCHI.format(payment); NumberFormat numFRA = NumberFormat.getCurrencyInstance(Locale.FRANCE); String france = numFRA.format(payment); System.out.println("US: " + us); System.out.println("India: " + india); System.out.println("China: " + china); System.out.println("France: " + france); }
}
Seems like cookies are disabled on this browser, please enable them to open this website
An unexpected error occurred. Please try reloading the page. If problem persists, please contact support@hackerrank.com
Java Currency Formatter
You are viewing a single comment's thread. Return to all comments →
public class Solution {
}