Advertisement
Icegoten

MakeChange

Nov 3rd, 2011
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.00 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class MakeChange
  4. {
  5.     static Scanner keyboard = new Scanner(System.in);
  6.    
  7.     static final int HALFDOLLAR = 50;
  8.     static final int QUARTER = 25;
  9.     static final int DIME = 10;
  10.     static final int NICKEL = 5;
  11.    
  12.     public static void main(String []args)
  13.     {
  14.         int change = 0;
  15.        
  16.         System.out.println("Enter the change in cents: ");
  17.         change = keyboard.nextInt();
  18.         System.out.println();
  19.        
  20.         System.out.println("The change you entered is " + change);
  21.        
  22.         System.out.println("You should return " + (change / HALFDOLLAR) + " half dollars.");
  23.         change = change % HALFDOLLAR;
  24.        
  25.         System.out.println("You should return " + (change / QUARTER) + " quarters.");
  26.         change = change % QUARTER;
  27.        
  28.         System.out.println("You should return " + (change / DIME) + " dimes.");
  29.         change = change % DIME;
  30.        
  31.         System.out.println("You should return " + (change / NICKEL) + " nickels.");
  32.         change = change % NICKEL;
  33.        
  34.         System.out.println("You should return " + change + " pennies.");
  35.  
  36.     }
  37.  
  38. }
  39.  
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement