Question
Write the code to format number in U.S. currency
Solution
VerifiedAnswered 1 year ago
Answered 1 year ago
We can write the code to format number 12345.678 in U.S. currency using the getCurrencyInstance method to which we parse the desired locale, and then format it with the format() method into which we also parse the amount that is to be formatted.
NumberFormat currencyFormat =NumberFormat.getCurrencyInstance(Locale.US);
System.out.println(currencyFormat.format(12345.678));
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
Create an account to view solutions
By signing up, you accept Quizlet's Terms of Service and Privacy Policy
More related questions
1/4
1/7