-
-
Notifications
You must be signed in to change notification settings - Fork 109
/
JavaCurrencyFormatter.java
32 lines (27 loc) · 1.27 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
import java.io.*;
import java.util.*;
import java.text.*;
public class JavaCurrencyFormatter {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
double payment = sc.nextDouble();
sc.close();
// NumberFormat nf = NumberFormat.getInstance();
// nf.setMaximumFractionDigits(2);
// nf.setMinimumFractionDigits(2);
// Currency us_currency = Currency.getInstance("USD");
// nf.setCurrency(us_currency);
// System.out.println("US: " + nf.format(payment));
// Currency in_currency = Currency.getInstance("INR");
// nf.setCurrency(in_currency);
// System.out.println("India: " + nf.format(payment));
NumberFormat us = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat india = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
NumberFormat china = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat france = NumberFormat.getCurrencyInstance(Locale.FRANCE);
System.out.println("US: " + us.format(payment));
System.out.println("India: " + india.format(payment));
System.out.println("China: " + china.format(payment));
System.out.println("France: " + france.format(payment));
}
}