You are viewing a single comment's thread. Return to all comments →
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 []locales={Locale.US,new Locale("en","IN"),Locale.CHINA,Locale.FRANCE}; String[]code={"USD","INR","CNY","EUR"}; String []names={"US","India","China","France"}; for(int i=0;i<locales.length;i++){ NumberFormat currency=NumberFormat.getCurrencyInstance(locales[i]); currency.setCurrency(Currency.getInstance(code[i])); String formatcurrency=currency.format(payment); System.out.println(names[i]+": "+formatcurrency); } } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Currency Formatter
You are viewing a single comment's thread. Return to all comments →