Search

# Java Currency Formatter | HACKERRANK

Asked: Anonymously |Category: JAVA

import java.io.*;

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(System.in);

double payment = scanner.nextDouble();

scanner.close();

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);

}

}

### Recent Posts

See All

#### Golf CodeChef Solution in Java - AskTheCode

CodeChef May Long Challenge Solution | Golf (LKDNGOLF) solution | AskTheCode Golf (LKDNGOLF) solution Problem: It's a lockdown. You’re bored in your house and are playing golf in the hallway. The hall

#### Solubility - CodeChef Solution in Java and C++| AskTheCode

CodeChef May Long Challenge Solution | Solubility (SOLBLTY) solution | AskTheCode Solubility (SOLBLTY) solution Problem: Suppose for a unit rise in temperature, the solubility of sugar in water increa

#### Valid Paths CodeChef Solution in C++ | AskTheCode

CodeChef May Long Challenge Solution | Valid Paths (VPATH) solution | AskTheCode Valid Paths (VPATH) CodeChef solution Problem: You are given a tree with N nodes numbered from 1 to N. A set S of nodes