Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class MakeChange
- {
- static Scanner keyboard = new Scanner(System.in);
- static final int HALFDOLLAR = 50;
- static final int QUARTER = 25;
- static final int DIME = 10;
- static final int NICKEL = 5;
- public static void main(String []args)
- {
- int change = 0;
- System.out.println("Enter the change in cents: ");
- change = keyboard.nextInt();
- System.out.println();
- System.out.println("The change you entered is " + change);
- System.out.println("You should return " + (change / HALFDOLLAR) + " half dollars.");
- change = change % HALFDOLLAR;
- System.out.println("You should return " + (change / QUARTER) + " quarters.");
- change = change % QUARTER;
- System.out.println("You should return " + (change / DIME) + " dimes.");
- change = change % DIME;
- System.out.println("You should return " + (change / NICKEL) + " nickels.");
- change = change % NICKEL;
- System.out.println("You should return " + change + " pennies.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement