-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJava_Currency_Formatter.java
More file actions
25 lines (19 loc) · 972 Bytes
/
Java_Currency_Formatter.java
File metadata and controls
25 lines (19 loc) · 972 Bytes
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
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();
scanner.close();
payment = Math.round(payment*100.0)/100.0;
// Write your code here.
NumberFormat usFormat = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat inFormate = NumberFormat.getCurrencyInstance(new Locale("en","IN"));
NumberFormat chinaFormate = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat franceFomate = NumberFormat.getCurrencyInstance(Locale.FRANCE);
System.out.println("US: " + usFormat.format(payment));
System.out.println("India: " + inFormate.format(payment));
System.out.println("China: " + chinaFormate.format(payment));
System.out.println("France: " + franceFomate.format(payment));
}
}