You are viewing a single comment's thread. Return to all comments →
I update all unicode until I get zero result from diff command, yet the grader still say it is wrong answer. definitely broken on java15
public static void main(String[] args) { try (final var sc = new Scanner(System.in)) { final var line = sc.nextLine().trim(); final var amount = Double.parseDouble(line); var formatter = NumberFormat.getCurrencyInstance(); var dfs = new DecimalFormatSymbols(); // US System.out.println("US: " + NumberFormat.getCurrencyInstance(Locale.US) .format(amount)); // India dfs.setCurrencySymbol("Rs."); ((DecimalFormat) formatter).setDecimalFormatSymbols(dfs); System.out.println("India: " + formatter.format(amount)); // China dfs.setCurrencySymbol("\uFFE5"); ((DecimalFormat) formatter).setDecimalFormatSymbols(dfs); System.out.println("China: " + formatter.format(amount)); // France formatter = NumberFormat.getCurrencyInstance(Locale.FRANCE); dfs = ((DecimalFormat) formatter).getDecimalFormatSymbols(); dfs.setCurrencySymbol("\u20AC"); ((DecimalFormat) formatter).setDecimalFormatSymbols(dfs); System.out.println("France: " + formatter.format(amount) .replace('\u202F', ' ') .replace('\u00A0', ' ')); } }
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 →
I update all unicode until I get zero result from diff command, yet the grader still say it is wrong answer. definitely broken on java15