Java Currency Formatter | HACKERRANK

Asked: Anonymously |Category: JAVA


import java.util.*;

import java.text.*;

import java.math.*;

import java.util.regex.*;

public class Solution {

public static void main(String[] args) {

Scanner scanner = new Scanner(;

double payment = scanner.nextDouble();


NumberFormat usf=NumberFormat.getCurrencyInstance(Locale.US);

NumberFormat csf=NumberFormat.getCurrencyInstance(Locale.CHINA);

NumberFormat fsf=NumberFormat.getCurrencyInstance(Locale.FRANCE);

NumberFormat isf=NumberFormat.getCurrencyInstance(new Locale("en","in"));

String us=usf.format(payment);

String india=isf.format(payment);

String china=csf.format(payment);

String france=fsf.format(payment);

System.out.println("US: " + us);

System.out.println("India: " + india);

System.out.println("China: " + china);

System.out.println("France: " + france);



2 views0 comments

Recent Posts

See All

Calculate BMI in Java | AskTheCode

Write a Java program that reads values for weight in kilograms and height in centimeters and prints out the BMI... interpretation of it...

"Believe you can and you're halfway there"