Quick question about numbers and decimals
I completed a project for school but I am having a little problem formatting numbers.
I have the following line
The line and the code works but my problem is the result it yields has too many decimals. I tried the following line but it did not work:
JOptionPane.showMessageDialog(null, "Subtotal: " + subTotal);
I tried placing the %5.2f outside the parenthesis and it did not work.
JOptionPane.showMessageDialog(null, "Subtotal: %5.2f" , total);
Can someone help me fix this error?