Files

32 lines
1.2 KiB
Java
Raw Permalink Normal View History

2017-02-12 00:31:12 -08:00
// Author: Rodney Shaghoulian
2018-07-27 16:45:56 -07:00
// Github: github.com/RodneyShag
// HackerRank: hackerrank.com/RodneyShag
2017-02-12 00:31:12 -08:00
2017-02-07 01:14:49 -08:00
import java.util.Scanner;
import java.text.NumberFormat;
import java.util.Locale;
public class Solution {
public static void main(String[] args) {
2017-04-05 18:42:35 -05:00
/* Save input */
Scanner scan = new Scanner(System.in);
2018-07-27 16:45:56 -07:00
double payment = scan.nextDouble();
2017-04-05 18:42:35 -05:00
scan.close();
2017-02-07 01:14:49 -08:00
2017-04-05 18:42:35 -05:00
/* Create custom Locale for India - I used the "IANA Language Subtag Registry" to find India's country code */
2017-02-07 01:14:49 -08:00
Locale indiaLocale = new Locale("en", "IN");
/* Create NumberFormats using Locales */
NumberFormat us = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat india = NumberFormat.getCurrencyInstance(indiaLocale);
NumberFormat china = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat france = NumberFormat.getCurrencyInstance(Locale.FRANCE);
/* Print output */
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));
}
}