Java Currency Formatter

Sort by

recency

|

879 Discussions

|

  • + 0 comments

    I tried different approaches but due to unicode characters the anwer never comes as valid. I even tried some solution from the comments but neither worked. this is my output, I can't see any difference

    Your Output (stdout)

    US: $12,324.13 India: Rs.12,324.13 China: ¥12,324.13 France: 12 324,13 €

    Expected Output

    US: $12,324.13 India: Rs.12,324.13 China: ¥12,324.13 France: 12 324,13 €

  • + 0 comments

    import java.util.; import java.text.;

    public class Solution {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        double payment = scanner.nextDouble();
        scanner.close();
    
        NumberFormat nfUS = NumberFormat.getCurrencyInstance(Locale.US);
        NumberFormat nfIN = NumberFormat.getCurrencyInstance(new Locale("en","IN"));
        NumberFormat nfCH = NumberFormat.getCurrencyInstance(Locale.CHINA);
        NumberFormat nfFR = NumberFormat.getCurrencyInstance(Locale.FRANCE);
    
        String us = nfUS.format(payment);
        String india = nfIN.format(payment);
        String china = nfCH.format(payment);
        String france = nfFR.format(payment);
    
    
        System.out.println("US: " + us);
        System.out.println("India: " + india);
        System.out.println("China: " + china);
        System.out.println("France: " + france);
    }
    

    }

    This is the solution. I hope that helped:0

  • + 0 comments

    RUN CODE WITH JAVA 8!!!!!

  • + 0 comments

    Java remains one of the most powerful and versatile programming languages out there! Cricbet99 club

  • + 0 comments

    rong Answer Input (stdin) 12324.134 Your Output (stdout) US: $12,324.13 India: Rs.12,324.13 China: ¥12,324.13 France: 12 324,13 €'