I am making a pizza order system in Java netbeans where the user has multiple toppings to choose from and displays the total amount in a message box. For example, the user choose small (pizza size), then selects 3 toppings the total will now be $5.5. If the user choose small (pizza size), then selects 7 toppings, the total will be $9.25 and vice versa. Any help will be appreciated.
Sample output below
My code for the confirm button
private void jButton_confirmOrderActionPerformed(java.awt.event.ActionEvent evt) {
float pizzaS_amount = (float) 4.00;
float toppings_amount = (float) 0.75;
float total = 0;
if (jRadioButton_pizzaS.isSelected()){
total = pizzaS_amount;
if (jCheckBox_pepperoni.isSelected()){
total = pizzaS_amount + toppings_amount;
if (jCheckBox_pepperoni.isSelected() && jCheckBox_extraCheese.isSelected()){
total += toppings_amount;
}
}
}
jTextArea_confirmOrder.append("total: " + total);
JOptionPane.showMessageDialog(null, jTextArea_confirmOrder, "CONFIRM ORDER", JOptionPane.INFORMATION_MESSAGE);
jTextArea_confirmOrder.setText(null);
}
Aucun commentaire:
Enregistrer un commentaire