- Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathjava-currency-formatter.java
More file actions
Latest commit
30 lines (24 loc) · 1000 Bytes
/
Copy pathjava-currency-formatter.java
File metadata and controls
30 lines (24 loc) · 1000 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
26
27
28
29
30
// Java > Introduction > Java Currency Formatter
// Format Currency in Java
//
// https://www.hackerrank.com/challenges/java-currency-formatter/problem
// challenge id: 23733
//
importjava.util.*;
importjava.text.*;
publicclassSolution {
publicstaticvoidmain(String[] args) {
Scannerscanner = newScanner(System.in);
doublepayment = scanner.nextDouble();
scanner.close();
// Write your code here.
Stringus = NumberFormat.getCurrencyInstance(Locale.US).format(payment);
Stringindia = NumberFormat.getCurrencyInstance(newLocale("en", "IN")).format(payment);
Stringchina = NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment);
Stringfrance = NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment);
System.out.println("US: " + us);
System.out.println("India: " + india);
System.out.println("China: " + china);
System.out.println("France: " + france);
}
}