-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava_currency_formatter.java
37 lines (27 loc) · 1.11 KB
/
java_currency_formatter.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
34
35
36
37
/*
Input -> 12324.134
Output -> US: $12,324.13
India: Rs.12,324.13
China: ¥12,324.13
France: 12 324,13 €
*/
import java.util.*;
import java.text.*;
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double payment = scanner.nextDouble();
NumberFormat usFormat = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat indiaFormat = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
NumberFormat chinaFormat = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat franceFormat = NumberFormat.getCurrencyInstance(Locale.FRANCE);
String us = usFormat.format(payment);
String india = indiaFormat.format(payment);
String china = chinaFormat.format(payment);
String france = franceFormat.format(payment);
System.out.println("US: " + us);
System.out.println("India: " + india);
System.out.println("China: " + china);
System.out.println("France: " + france);
}
}