Skip to content

Commit

Permalink
add Java Currency Formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
= committed Jul 22, 2020
1 parent d53bdb7 commit 7663d74
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Java/01. Introduction/13. Java Currency Formatter/Solution.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Problem: https://www.hackerrank.com/challenges/java-currency-formatter
// Difficulty: Easy
// Score: 15


import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;

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.
System.out.println("US: " + NumberFormat.getCurrencyInstance(Locale.US).format(payment));
System.out.println("India: " + NumberFormat.getCurrencyInstance(new Locale("en", "IN")).format(payment));
System.out.println("China: " + NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment));
System.out.println("France: " + NumberFormat.getCurrencyInstance(Locale.FRANCE).format(payment));

}
}

0 comments on commit 7663d74

Please sign in to comment.