-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathJavaCurrencyFormatter.java
33 lines (27 loc) · 1.13 KB
/
JavaCurrencyFormatter.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.Locale;
import java.text.NumberFormat;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double payment = scanner.nextDouble();
scanner.close();
Locale localeIndia = new Locale("en","IN");
NumberFormat us = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat india = NumberFormat.getCurrencyInstance(localeIndia);
NumberFormat china = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat france = NumberFormat.getCurrencyInstance(Locale.FRANCE);
String usFormat = us.format(payment);
String indiaFormat = india.format(payment);
String chinaFormat = china.format(payment);
String franceFormat = france.format(payment);
System.out.println("US: " + usFormat);
System.out.println("India: " + indiaFormat);
System.out.println("China: " + chinaFormat);
System.out.println("France: " + franceFormat);
}
}