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.
public class Solution {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double payment = scanner.nextDouble();
scanner.close();
NumberFormat u = NumberFormat.getCurrencyInstance(Locale.US);
NumberFormat i = NumberFormat.getCurrencyInstance(new Locale("en", "in"));
NumberFormat c = NumberFormat.getCurrencyInstance(Locale.CHINA);
NumberFormat f = NumberFormat.getCurrencyInstance(Locale.FRANCE);
System.out.println("US: " + u.format(payment));
System.out.println("India: " + i.format(payment));
System.out.println("China: " + c.format(payment));
System.out.println("France: " + f.format(payment));
}
}
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 →
import java.io.; import java.util.; import java.text.*;
public class Solution { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double payment = scanner.nextDouble(); scanner.close();
} }