阅读背景:

没有明显的错误,但GUI仍然无法正常工作?

来源:互联网 

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



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: