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.
Java Currency Formatter
Java Currency Formatter
Sort by
recency
|
817 Discussions
|
Please Login in order to post a comment
Indian format only worked as expected on the result in java 8
My code, when run, prints the Chinese yuan with two stikes on Y, while the expected output demands the yuan character with only one strike on Y. Hence, my code is not passing the test case.
Any suggestions are cited and welcome.
public class Solution {
double payment = scanner.nextDouble(); var u = NumberFormat.getCurrencyInstance(Locale.US); var i = NumberFormat.getCurrencyInstance(new Locale("en", "IN")); var c = NumberFormat.getCurrencyInstance(new Locale("zh","CN")); var f = NumberFormat.getCurrencyInstance(Locale.FRANCE); System.out.println("US: "+u.format(payment)); System.out.println("India: "+i.format(payment).replace(i.getCurrency().getSymbol(), "Rs.")); System.out.println("China: "+c.format(payment)); System.out.println("France: "+f.format(payment));
}
public class Solution {
}
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}
This code is working
import java.util.; import java.text.;
public class Solution {
}