Java Currency Formatter

  • + 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();
    
        // Write your code here.
        NumberFormat usnf = NumberFormat.getCurrencyInstance(Locale.US);
        NumberFormat innf = NumberFormat.getCurrencyInstance(new Locale("en", "IN"));
        NumberFormat chinf = NumberFormat.getCurrencyInstance(Locale.CHINA);
        NumberFormat frnf = NumberFormat.getCurrencyInstance(Locale.FRANCE);
    
        System.out.println("US: " + usnf.format(payment));
        System.out.println("India: " + innf.format(payment));
        System.out.println("China: " + chinf.format(payment));
        System.out.println("France: " + frnf.format(payment));
    }
    

    }