We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Since Java 15 has new updates therefore I prefer to use Java 8 for this question
Try this in Java 8:
import java.io.;
import java.util.;
import java.text.*;
public class Solution {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
double db = sc.nextDouble();
NumberFormat nf1 = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat nf2 = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
NumberFormat nf3 = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat nf4 = NumberFormat.getCurrencyInstance(Locale.FRANCE);
System.out.println("US: "+nf1.format(db));
System.out.println("India: "+nf2.format(db));
System.out.println("China: "+nf3.format(db));
System.out.println("France: "+nf4.format(db));
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Currency Formatter
You are viewing a single comment's thread. Return to all comments →
Since Java 15 has new updates therefore I prefer to use Java 8 for this question Try this in Java 8: import java.io.; import java.util.; import java.text.*;
public class Solution {
}