Java Currency Formatter

Sort by

recency

|

884 Discussions

|

  • + 0 comments

    This is a great example of how Java’s NumberFormat class can be used to handle international currency formatting. Ekbet com

  • + 0 comments

    I don't know, Why it shows error in this code.

    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 payment = sc.nextDouble();
            
            System.out.println("US: " + NumberFormat.getCurrencyInstance(Locale.US).format(payment));
            System.out.println("India: " + ("Rs."+NumberFormat.getCurrencyInstance(new Locale("en", "IN")).format(payment).substring(1)));
            System.out.println("China: " + NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment).replace("\u00A5", "\uFFE5"));
            System.out.println("France: " + NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment).replace(' ', '\u00A0'));
        }
    }
    

    For this my output and expected output is similiar, I have also checked the unicode for the symbols.

  • + 0 comments

    It’s a perfect introduction to handling internationalization because you not only format numbers into currency but also see how different countries represent money in their own style. Cricket 99.club

  • + 0 comments

    The problem seems outdated. I got the correct INR symbol with Java 15, but could only pass the test with Java 8.

  • + 0 comments

    It’s great for making applications more user-friendly and globally adaptable. Cricbet99.club login