Last active
November 29, 2018 16:51
-
-
Save SushmaBaliza/6375ce872ce542c0c9f189bb867edd08 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main.Java; | |
import java.util.Scanner; | |
import java.text.NumberFormat; | |
import java.util.Locale; | |
public class JavaCurrencyFormatter { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
double payment = scanner.nextDouble(); | |
scanner.close(); | |
Locale indiaLocale = new Locale("en", "IN"); | |
NumberFormat us = NumberFormat.getCurrencyInstance(Locale.US); | |
NumberFormat india=NumberFormat.getCurrencyInstance(indiaLocale); | |
NumberFormat china=NumberFormat.getCurrencyInstance(Locale.CHINA); | |
NumberFormat france=NumberFormat.getCurrencyInstance(Locale.FRANCE); | |
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)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment