Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "P35.00"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at OrderSystems.OrderSystem.jButton3MouseClicked(OrderSystem.java:419)
at OrderSystems.OrderSystem.access$900(OrderSystem.java:14)
at OrderSystems.OrderSystem$10.mouseClicked(OrderSystem.java:241)
jButton3をクリックすると、このエラーが発生します。私のコードをheres。Java番号形式の例外です。
private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {
double sub = Double.parseDouble(sub_field.getText());
double vat = Double.parseDouble(vat_field.getText());
double allTotal = (sub + vat);
String iTotal = String.format("%.2f", allTotal);
total_field.setText(iTotal);
}
これは
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
double ham = Double.parseDouble(ham_field.getText());
double burger = Double.parseDouble(burger_field.getText());
double bacon = Double.parseDouble(bacon_field.getText());
double bac = bacon * 5;
double harm = ham * 10;
double burg = burger *20;
double sub = harm + burg + bac;
String sub_com = String.format("P%.2f", sub);
sub_field.setText(sub_com);
}
エラーメッセージのどの部分が不明ですか? –