title: Java class to break down change into coins?
body: <p>I am working on a java assignment where you enter the price of an object and the amount a theoretical customer handed you for the item. Then the program returns how much you owe them, and breaks it down into dollars, quarters, dimes, nickles, and pennies that you should give them.</p>
  
  <p>Basically here's what it would look like when it runs</p>
  
  <blockquote>
    <p>What was the purchase price? (exclude the decimal in calculation if it helps 
    you)<br>
    $98.50<br>
    How much money did you pay with? (exclude the decimal)<br>
    $100.00<br>
    The purchase price was $98.50<br>
    You payed $100.0<br>
    You received $1.50 in change.<br>
    0 one hundred dollar bill(s)<br>
    0 fifty dollar bill(s)<br>
    0 twenty dollar bill(s)<br>
    0 ten dollar bill(s)<br>
    0 five dollar bill(s)<br>
    1 one dollar bill(s)<br>
    2 quarter(s)<br>
    0 dime(s)<br>
    0 nickel(s)<br>
    0 penny/pennies  </p>
  </blockquote>
  
  <p>I understand most of it, but I cant seem to wrap my mind around the breakdown of the change handed back. Here's my code so far, but if someone could show me how to break down the change.</p>
  
  <pre><code>import java.util.*;
  public class ChangeTendered {
  
      public static void main(String[] args){
  
          Scanner scan = new Scanner(System.in);
  
          System.out.println("Enter the purchase price: ");
          double price = scan.nextDouble();
          System.out.println("Enter the amount payed: ");
          double ammountPayed = scan.nextDouble();
  
          double changeDue = ammountPayed - price;
  
          int dollars = (int)changeDue;
  
          System.out.println("Return"+ dollars+ "Dollars");
  
          scan.close();
      }
  
  }
  </code></pre>
  
  <p>On a side note, I just cast the changeDue to an int in order to chop off the decimal and get the dollars due, if that caused any confusion.</p>