/*
http://www.javacommerce.com/displaypage.jsp?name=notes/chap10/progexercises10.sql&id=18218
(some part of the program specs are edited from the site written above)
CORRECT CHANGE
When cashiers in a store give you change, they first try to
“fit” dollars (100 cents coins) into the amount you get back,
then try to “fit” quarters (25 cent coins) into what is left
over, they try to “fit” dimes (10 cent coins) into what is
now left over, then try to “fit” nickels (5 cent coins)
into what is left, and finally are left with a few odd
cents. For example, say that your change is 163 cents:
One dollar fits into 163, leaving 63 cents.
Two quarters fit into 63 cents, leaving 13 cents.
One dime fits into 13 cents, leaving 3 cents.
No nickels are needed.
Three cents are left.
Your change is : 1 dollar, 2 quarter, 1 dime, 0 nickel, and 3 cents.
Write a program that compute the change due to a buyer (in cents) and writes out how many dollars, quarters, dimes, nickels, and pennies she is due. All variables and all math in this program will be integers. If you are stuck, it will help to do an example problem with paper and pencil.
*/
class change {
public static void main(String args[]) {
int ch = 163, dollar, quarter, dime, nickel, cents;
dollar = ch / 100;
ch = ch % 100;
quarter = ch / 25;
ch = ch % 25;
dime = ch / 10;
ch = ch % 10;
nickel = ch / 5;
ch = ch % 5;
cents = ch;
System.out.print(“Your change is : “);
System.out.print(dollar + ” dollar, ” + quarter + ” quarter, “);
System.out.print(dime + ” dime, ” + nickel + ” nickel, and “);
System.out.print(cents + ” cents”);
}
}