import javax.swing.*; public class CashierFive { public void ringUpCustomer(String customerName) { String item; double total = 0.0, milkPrice = 3.50, bottleWaterPrice = 1.0; double sugarPrice = 1.25; do { item = JOptionPane.showInputDialog("Enter Item Description"); if (item.equals("milk")) { total = total + milkPrice; } else if (item.equals("bottleWater")) { total = total + bottleWaterPrice; } else if (item.equals("sugar")) { total = total + sugarPrice; } } while (!item.equals("end")); String reply = "Your total is: $" + total + "\nPlease enter payment amount."; // Notice using showInputDialog for output and input String paymentString = JOptionPane.showInputDialog(reply); double payment = Double.parseDouble(paymentString); while (payment < total) { String wrongAmountReply = "Insufficient payment provided. \n" + reply; paymentString = JOptionPane.showInputDialog(wrongAmountReply); payment = Double.parseDouble(paymentString); } reply = customerName + ", thank you for shopping with us.\n"; reply = reply + "Your change is: $" + (payment - total); JOptionPane.showMessageDialog(null, reply); } }