CJCoding With Joseph
15per day

NumberFormat Parse and Reformat

Read a comma-formatted number string, parse it back to a numeric value with NumberFormat, then reprint it with exactly 2 decimal places.

Expected Output:
Parsed: 12345.60

Use sc.nextLine() to read the string, then NumberFormat.getNumberInstance(Locale.US).parse(text) to convert it. parse() returns a Number object - call .doubleValue() to get a double. The method throws ParseException so main needs throws Exception.

⚠️ AUTO-INPUT MODE: The input stream will automatically contain '12,345.6\n'. Use sc.nextLine() to read it.

Expected Output:

Parsed: 12345.60
Topics:
Miscellaneous
📥 Auto-Input:
12,345.6\n
This input is automatically fed to your program's stdin
Code Editor
1
Tab to indent · Ctrl+Enter to run · Ctrl+Space to expand shortcuts (sysout, psvm, fori)

Your Output

Run your code to see the output here...

Test Cases

Run your code to see test case results.