top of page
Click here to go to the home page of AskTheCode.

Java Currency Formatter | HackerRank

Team ATC

Random Post | #AskTheCode

 

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(); Locale INDIA = new Locale("en", "IN"); String us = NumberFormat.getCurrencyInstance(Locale.US).format(payment); String india = NumberFormat.getCurrencyInstance(INDIA).format(payment); String china = NumberFormat.getCurrencyInstance(Locale.CHINA).format(payment); String france = NumberFormat.getCurrencyInstance(Locale.FRANCE).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

Comments


bottom of page