/* 
   ChangeCoinsAppTwo.java      Author: Koffman and Wolz
   Application class with readInt() method that uses CoinChanger
*/
import javax.swing.*;
public class ChangeCoinsAppTwo {

  // methods
 
  // postcondition: Displays prompt in a dialog window and
  //   returns an int value corresponding to 
  //   the characters typed in by the program user.
  private static int readInt(String prompt) {
    String intStr = JOptionPane.showInputDialog(prompt);
    return Integer.parseInt(intStr);
  }

  public static void main(String[] args) {
    //Create a CoinChanger object.
    CoinChanger cC = new CoinChanger();

    // Store the number of each kind of coin in the CoinChanger object.
    cC.setPennies(readInt("Number of pennies"));
    cC.setNickels(readInt("Number of nickels"));
    cC.setDimes(readInt("Number of dimes"));
    cC.setQuarters(readInt("Number of quarters"));

    // Display the value of the coins in dollars and change.
    String message = cC.toString() +
                  "\nCoin collection value is $" +
                  cC.findDollars() + "." + cC.findChange();
    JOptionPane.showMessageDialog(null, message);
  }
}

