<\/span><\/h2>\n\n\n\nGiven a double-precision number, payment<\/em><\/strong>, denoting an amount of money, use the NumberFormat class’ getCurrencyInstance method to convert payment <\/em><\/strong>into the US, Indian, Chinese, and French currency formats. Then print the formatted values as follows:<\/p>\n\n\n\n US: formattedPayment\n India: formattedPayment\n China: formattedPayment\n France: formattedPayment<\/code><\/pre>\n\n\n\nwhere formattedPayment<\/em> <\/strong>is payment<\/em><\/strong> formatted according to the appropriate Locale’s currency.<\/p>\n\n\n\nNote:<\/strong> India does not have a built-in Locale, so you must construct one where the language is en (i.e., English).<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nA single double-precision number denoting payment<\/em><\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h4>\n\n\n\n0 <= payment <= 10<\/em><\/strong>9<\/em><\/strong><\/sup><\/p>\n\n\n\n<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nOn the first line, print US: u where u <\/em><\/strong>is payment<\/em><\/strong> formatted for US currency.
On the second line, print India: i where u <\/em><\/strong>is payment<\/em><\/strong> formatted for Indian currency.
On the third line, print China: c where u <\/em><\/strong>is payment<\/em><\/strong> formatted for Chinese currency.
On the fourth line, print France: f, where u <\/em><\/strong>is payment<\/em><\/strong> formatted for French currency.<\/p>\n\n\n\n<\/span>Sample Input<\/strong><\/span><\/h5>\n\n\n\n 12324.134<\/code><\/pre>\n\n\n\n<\/span>Sample Output<\/strong><\/span><\/h5>\n\n\n\n US: $12,324.13\n India: Rs.12,324.13\n China: \uffe512,324.13\n France: 12 324,13 \u20ac<\/code><\/pre>\n\n\n\n<\/span>Explanation<\/strong><\/span><\/h5>\n\n\n\nEach line contains the value of payment <\/em><\/strong>formatted according to the four countries’ respective currencies.<\/p>\n\n\n\n<\/span>Solution –<\/strong> Java Currency Formatter<\/strong><\/span><\/h2>\n\n\n\nimport java.io.*;\nimport java.util.*;\nimport java.text.*;\nimport java.math.*;\nimport java.util.regex.*;\n\npublic class Solution {\n \n public static void main(String[] args) {\n Scanner scanner = new Scanner(System.in);\n double payment = scanner.nextDouble();\n scanner.close();\n\n \/\/ Write your code here.\n String us = NumberFormat.getCurrencyInstance(Locale.US).format(payment);\n String india = NumberFormat.getCurrencyInstance(new Locale(\"en\",\"in\")).format(payment);\n String china = NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment);\n String france = NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment);\n \n System.out.println(\"US: \" + us);\n System.out.println(\"India: \" + india);\n System.out.println(\"China: \" + china);\n System.out.println(\"France: \" + france);\n }\n}<\/pre>\n\n\n\n