-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCurrencyFormatter.java
More file actions
26 lines (21 loc) · 869 Bytes
/
CurrencyFormatter.java
File metadata and controls
26 lines (21 loc) · 869 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
/*
https://www.hackerrank.com/challenges/java-currency-formatter
*/
import java.util.Scanner;
import java.util.Locale;
import java.text.NumberFormat;
public class Main{
public static Scanner input = new Scanner(System.in);
public static Locale localeINDIA = new Locale("en","IN");
public static void main(String[] args) {
double money = input.nextDouble();
NumberFormat us = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat india = NumberFormat.getCurrencyInstance(localeINDIA);
NumberFormat china = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat france = NumberFormat.getCurrencyInstance(Locale.FRANCE);
System.out.println("US: " + us.format(money));
System.out.println("India: " + india.format(money));
System.out.println("China: " + china.format(money));
System.out.println("France: " + france.format(money));
}
}