You are viewing a single comment's thread. Return to all comments →
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double payment = scanner.nextDouble(); scanner.close(); Locale india = new Locale("en", "IN"); System.out.println("US: " + formatPayment(Locale.US, payment)); System.out.println("India: " + formatPayment(india, payment)); System.out.println("China: " + formatPayment(Locale.CHINA, payment)); System.out.println("France: " + formatPayment(Locale.FRANCE, payment)); } public static String formatPayment(Locale locale, double payment) { NumberFormat nf = NumberFormat.getCurrencyInstance(locale); return nf.format(payment); } }
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 →