Java Currency Formatter

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