import javax.swing.JOptionPane; /** This class tests the Purse class by prompting the user to add coins into a purse and computing the total value of the purse. */ public class PurseTest { public static void main(String[] args) { double NICKEL_VALUE = 0.05; double DIME_VALUE = 0.1; double QUARTER_VALUE = 0.25; Purse myPurse = new Purse(); String input = JOptionPane.showInputDialog("Enter coin name or Cancel") ; while ( input != null ) { System.out.println("You entered: " + input) ; double value = 0; if (input.equalsIgnoreCase("nickel")) value = NICKEL_VALUE; else if (input.equalsIgnoreCase("dime")) value = DIME_VALUE; else if (input.equalsIgnoreCase("quarter")) value = QUARTER_VALUE; if (value != 0) { Coin c = new Coin(value, input); myPurse.add(c); double totalValue = myPurse.getTotal(); System.out.println("The total is " + totalValue); } input = JOptionPane.showInputDialog("Enter coin name or Cancel") ; } System.exit(0); } } /* sample output: You entered: dime The total is 0.1 You entered: Quarter The total is 0.35 You entered: NICKEL The total is 0.39999999999999997 You entered: nickel The total is 0.44999999999999996 You entered: quarter The total is 0.7 You entered: penny You entered: peso */