title: Printing Result based on Input from JOptionPane
body: <p>I am student, trying to finish a homework lab. Right now I am struggling to use the input from JOptionPane to display the results based on the input. There are two files to my lab, the CoinCounterTester.java and the CoinCounter.java. Both compile but it should print the total numbers of dollars and the total number of cents (teachers instructions) "Output should be in the console window, and should demonstrate the use of  and  escape sequences". I'm not sure if any part of the tester is correct but I think the JOptionPane methods are correct. I also think I'm supposed to parse them to get them into integer form , however I do not know how to print the designated number of dollars and number of cents left over based on user input. Can anyone explain?</p>
  
  <p>Thanks</p>
  
  <p>Edit:
  Ok the answer seems like its correct but I'm confused about using the constructor call. What would you put for the parameters for the constructor call, I put</p>
  
  <pre><code>CoinCounter coinCounter = new CoinCounter(int quarters, int dimes, int nickels, int pennies); 
  </code></pre>
  
  <p>but got seven errors</p>
  
  <p>Edit 2:</p>
  
  <p>I have now not included the variable type as well wisely suggested and input </p>
  
  <pre><code>CoinCounter coinCounter = new CoinCounter(quarters, dimes, nickels, pennies);
  </code></pre>
  
  <p>but I still get 4 errors (error cannot find symbol) :(. Can anyone suggest a correction please?</p>
  
  <p>Edit 3: Added the println statements and moved the constructor call to the bottom but whenever I run the program I cannot get the file to print the number of dollars and the number of cents?!</p>
  
  <pre><code>import javax.swing.JOptionPane;
  
  /**
   * A class to test the CoinCounter class
   */
  
  public class CoinCounterTester
  {
      /**
       * Tests methods of the CoinCounter class
       * @param args not used
       */
  
  
  
      public static void main(String[] args)
      {
  
  
          String quarter = JOptionPane.showInputDialog("Enter the quantity of quarters");
          int quarters = Integer.parseInt(quarter);
  
          String dime = JOptionPane.showInputDialog("Enter the quantity of dimes");
          int dimes = Integer.parseInt(dime);
  
          String nickel = JOptionPane.showInputDialog("Enter the quantity of nickels");
          int nickels = Integer.parseInt(nickel);
  
          String penny = JOptionPane.showInputDialog("Enter the quantity of pennies");
          int pennies = Integer.parseInt(penny);
  
  
  
          CoinCounter coinCounter = new CoinCounter(quarters, dimes, nickels, pennies);
  
          System.out.println(coinCounter.getDollars());
          System.out.println(coinCounter.getCents());
  
  
  
  
  
  
          System.exit(0);
  
      }
  }
  
  
  
  
   /**
   * A CoinCounter has a specific number of cents.  It can provide the number of dollars and the
   * number of cents that it contains
   */
   public class CoinCounter
   {
      // constants
      //*** These are class constants so they need public static
      public static final int QUARTER_VALUE = 25;
      public static final int DIME_VALUE = 10;
      public static final int NICKEL_VALUE = 5;
      public static final int PENNY_VALUE = 1;
      public static final int PENNY_PER_DOLLAR_VALUE = 100;
  
      // instance field (one - holds the total number of cents EX:  8,534)
      private int total;
  
      /**
       * Constructs a CoinCounter object with a specified number of pennies,
       * nickels, dimes and quarters
       * @param quarterAmount the amount of quarters
       * @param dimeAmount the amount of dimes
       * @param nickelAmount the amount of nickels
       * @param pennyAmount the amount of pennies
       */
      public CoinCounter(int quarters, int dimes, int nickels, int pennies)
      {
          total = quarters * QUARTER_VALUE + nickels * NICKEL_VALUE + dimes * DIME_VALUE + pennies;
  
  
  
      }
      // add remaining methods as described
  
      /**
       * getDollars returns the number of dollars in the CoinCounter
       *  @return the number of dollars
      */
      public int getDollars()
      {
          int dollars = (int) total / PENNY_PER_DOLLAR_VALUE;
          return dollars;
      }
      /**
       * getCents returns the number the numbers of cents left over after the dollars are removed
       *  @return the number of cents left over
      */
      public int getCents()
      {
          int cents = total % PENNY_PER_DOLLAR_VALUE;
          return cents;
      }
  
  
   }
  </code></pre>