We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
I thought I was going insane, I tried so many diffrent ways that "looked" correct but none worked until i gave up and looked in the comments.
This is the code i wrote (slightly more cleaned up) that didnt work on the JAVA 15 version. Change to 7 or 8.
publicstaticvoidmain(String[]args){/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */Scannersc=newScanner(System.in);doublemunny=sc.nextDouble();NumberFormatUS=NumberFormat.getCurrencyInstance();US.setCurrency(Currency.getInstance(Locale.US));DecimalFormatdfIndia=newDecimalFormat("#,###.00");NumberFormatchina=NumberFormat.getCurrencyInstance(Locale.CHINA);NumberFormatfrance=NumberFormat.getCurrencyInstance(Locale.FRANCE);System.out.println("US: "+US.format(munny));System.out.println("India: Rs."+dfIndia.format(munny));System.out.println("China: "+china.format(munny));System.out.println("France: "+france.format(munny));sc.close();}}
Cookie support is required to access HackerRank
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 →
JAVA 15 currently does not work
I thought I was going insane, I tried so many diffrent ways that "looked" correct but none worked until i gave up and looked in the comments.
This is the code i wrote (slightly more cleaned up) that didnt work on the JAVA 15 version. Change to 7 or 8.