Java Currency Formatter

Sort by

recency

|

885 Discussions

|

  • + 0 comments

    This code may help you understand essier

     // Write your code here.
     Locale INDIA = new Locale("en", "IN", "Rs.");
            NumberFormat Nus = NumberFormat.getCurrencyInstance(Locale.US);
            NumberFormat Nindia = NumberFormat.getCurrencyInstance(INDIA);
            NumberFormat Nchina = NumberFormat.getCurrencyInstance(Locale.CHINA);
            NumberFormat Nfrance = NumberFormat.getCurrencyInstance(Locale.FRANCE);
            // Write your code here.
            String us = Nus.format(payment);
            String india = Nindia.format(payment);
            String china = Nchina.format(payment);
            String france = Nfrance.format(payment);
    
        String india = Nindia.format(payment);
        String china = Nchina.format(payment);
        String france = Nfrance.format(payment);
    

    `

  • + 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.