I need program to show only 2 numbers after decimal in answer window. And it shows me a lot more. I have "import java.text.DecimalFormat;" but it doesn't work. Maybe I put it somewhere wrong. Here is my code. How should I make answer to show only 2 number after decimal?
double pb, pc = 0;
try {
pb=Double.parseDouble(pakavimoPlotas.getText());
}
catch (Exception e) {
JOptionPane.showMessageDialog(this, "Blogai įvestas pakavimo plotas",
"ERROR", JOptionPane.ERROR_MESSAGE);
}
pb=Double.parseDouble(pakavimoPlotas.getText());
pc=pb*0.17;
pakavimoKaina.setText(""+pc);
pakavimoKaina2.setText(""+pc+" EUR");