I have this code:
我有这个代码:
private void discountButtonActionPerformed(java.awt.event.ActionEvent evt) {
double purchasePrice, discount, discountAmount;
DecimalFormat x = new DecimalFormat("$##.00");
purchasePrice = Double.parseDouble(inputPurchase.getText());
discount = 0.1;
if (purchasePrice < 10) {
outputDiscountAmount.setText(x.format(0));
outputPrice.setText(x.format(purchasePrice));
} else {
outputDiscountAmount.setText(x.format(purchasePrice * discount));
discountAmount = purchasePrice - Double.parseDouble(outputDiscountAmount.getText());
outputPrice.setText(x.format(discountAmount));
//Not sure whether the discountAmount variable should be in the "else"
//brackets or at the top. If it is at the top nothing works.
//If where it is presently seen, outputDiscountAmount works, but outputPrice doesn't.
//Don't know what's wrong.
}
}
private void disc