Please help. I get this error after the prompts from the Scanner are displayed to the console:
Exception in thread \"main\" java.util.IllegalFormatPrecisionExcep
A: Because your format specifiers don't match input arguments used in the printf
method.
Use %f
rather than %d
as the format specifier character for double
values
System.out.printf("Diamond Cost: $%,.2f \n", diamondCost);
^
In addition %
requires an additional %
to escape that character
System.out.printf("State Tax @ 10%%: $%,.2f \n", stateTax);
Finally, remove the unnecessary dot character
System.out.printf("Number Ordered: $%,.2d \n", numOrdered);
^
Read: Formatter javadoc